LLVM  10.0.0
VEISelLowering.cpp
Go to the documentation of this file.
1 //===-- VEISelLowering.cpp - VE DAG Lowering Implementation ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the interfaces that VE uses to lower LLVM code into a
10 // selection DAG.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "VEISelLowering.h"
15 #include "VERegisterInfo.h"
16 #include "VETargetMachine.h"
17 #include "llvm/ADT/StringSwitch.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Function.h"
28 #include "llvm/IR/Module.h"
30 #include "llvm/Support/KnownBits.h"
31 using namespace llvm;
32 
33 #define DEBUG_TYPE "ve-lower"
34 
35 //===----------------------------------------------------------------------===//
36 // Calling Convention Implementation
37 //===----------------------------------------------------------------------===//
38 
39 #include "VEGenCallingConv.inc"
40 
42  CallingConv::ID CallConv, MachineFunction &MF, bool IsVarArg,
44  assert(!IsVarArg && "TODO implement var args");
45  assert(Outs.empty() && "TODO implement return values");
46  return true; // TODO support more than 'ret void'
47 }
48 
49 SDValue
51  bool IsVarArg,
53  const SmallVectorImpl<SDValue> &OutVals,
54  const SDLoc &DL, SelectionDAG &DAG) const {
55  assert(!IsVarArg && "TODO implement var args");
56  assert(Outs.empty() && "TODO implement return values");
57  assert(OutVals.empty() && "TODO implement return values");
58 
59  SmallVector<SDValue, 4> RetOps(1, Chain);
60  RetOps[0] = Chain; // Update chain.
61  return DAG.getNode(VEISD::RET_FLAG, DL, MVT::Other, RetOps);
62 }
63 
65  SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
66  const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
67  SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
68  assert(!IsVarArg && "TODO implement var args");
69  assert(Ins.empty() && "TODO implement input arguments");
70  return Chain;
71 }
72 
73 // FIXME? Maybe this could be a TableGen attribute on some registers and
74 // this table could be generated automatically from RegInfo.
76  const MachineFunction &MF) const {
78  .Case("sp", VE::SX11) // Stack pointer
79  .Case("fp", VE::SX9) // Frame pointer
80  .Case("sl", VE::SX8) // Stack limit
81  .Case("lr", VE::SX10) // Link regsiter
82  .Case("tp", VE::SX14) // Thread pointer
83  .Case("outer", VE::SX12) // Outer regiser
84  .Case("info", VE::SX17) // Info area register
85  .Case("got", VE::SX15) // Global offset table register
86  .Case("plt", VE::SX16) // Procedure linkage table register
87  .Default(0);
88 
89  if (Reg)
90  return Reg;
91 
92  report_fatal_error("Invalid register name global variable");
93 }
94 
95 //===----------------------------------------------------------------------===//
96 // TargetLowering Implementation
97 //===----------------------------------------------------------------------===//
98 
100  const VESubtarget &STI)
101  : TargetLowering(TM), Subtarget(&STI) {
102  // Instructions which use registers as conditionals examine all the
103  // bits (as does the pseudo SELECT_CC expansion). I don't think it
104  // matters much whether it's ZeroOrOneBooleanContent, or
105  // ZeroOrNegativeOneBooleanContent, so, arbitrarily choose the
106  // former.
109 
110  // Set up the register classes.
111  addRegisterClass(MVT::i64, &VE::I64RegClass);
112 
114 
115  // Set function alignment to 16 bytes
117 
118  // VE stores all argument by 8 bytes alignment
120 
122 }
123 
124 const char *VETargetLowering::getTargetNodeName(unsigned Opcode) const {
125  switch ((VEISD::NodeType)Opcode) {
126  case VEISD::FIRST_NUMBER:
127  break;
128  case VEISD::RET_FLAG:
129  return "VEISD::RET_FLAG";
130  }
131  return nullptr;
132 }
133 
135  EVT VT) const {
136  return MVT::i64;
137 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
LLVMContext & Context
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
unsigned Reg
VETargetLowering(const TargetMachine &TM, const VESubtarget &STI)
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
getSetCCResultType - Return the ISD::SETCC ValueType
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
const VERegisterInfo * getRegisterInfo() const override
Definition: VESubtarget.h:48
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose...
void setMinFunctionAlignment(Align Alignment)
Set the target&#39;s minimum function alignment.
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &ArgsFlags, LLVMContext &Context) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:63
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
Extended Value Type.
Definition: ValueTypes.h:34
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:223
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
Module.h This file contains the declarations for the Module class.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array...
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
void setMinStackArgumentAlignment(Align Alignment)
Set the minimum stack alignment of an argument.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Wrapper class representing virtual and physical registers.
Definition: Register.h:19