32 #define DEBUG_TYPE "irtranslator"
44 std::string ErrStorage;
46 Err << Message <<
": " << V <<
'\n';
60 unsigned IRTranslator::getOrCreateVReg(
const Value &Val) {
61 unsigned &ValReg = ValToVReg[&Val];
67 "Don't know how to create an empty vreg");
71 if (
auto CV = dyn_cast<Constant>(&Val)) {
72 bool Success = translate(*CV, VReg);
86 int IRTranslator::getOrCreateFrameIndex(
const AllocaInst &AI) {
87 if (FrameIndices.find(&AI) != FrameIndices.end())
88 return FrameIndices[&AI];
92 ElementSize * cast<ConstantInt>(AI.
getArraySize())->getZExtValue();
95 Size = std::max(Size, 1u);
101 int &FI = FrameIndices[&AI];
106 unsigned IRTranslator::getMemOpAlignment(
const Instruction &
I) {
107 unsigned Alignment = 0;
108 Type *ValTy =
nullptr;
109 if (
const StoreInst *SI = dyn_cast<StoreInst>(&I)) {
110 Alignment =
SI->getAlignment();
111 ValTy =
SI->getValueOperand()->getType();
112 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(&I)) {
113 Alignment = LI->getAlignment();
114 ValTy = LI->getType();
137 bool IRTranslator::translateBinaryOp(
unsigned Opcode,
const User &U,
145 unsigned Op0 = getOrCreateVReg(*U.
getOperand(0));
146 unsigned Op1 = getOrCreateVReg(*U.
getOperand(1));
147 unsigned Res = getOrCreateVReg(U);
152 bool IRTranslator::translateCompare(
const User &U,
155 unsigned Op0 = getOrCreateVReg(*U.
getOperand(0));
156 unsigned Op1 = getOrCreateVReg(*U.
getOperand(1));
157 unsigned Res = getOrCreateVReg(U);
160 cast<ConstantExpr>(U).getPredicate());
163 MIRBuilder.
buildICmp(Pred, Res, Op0, Op1);
165 MIRBuilder.
buildFCmp(Pred, Res, Op0, Op1);
176 return CLI->
lowerReturn(MIRBuilder, Ret, !Ret ? 0 : getOrCreateVReg(*Ret));
180 const BranchInst &BrInst = cast<BranchInst>(U);
201 bool IRTranslator::translateSwitch(
const User &U,
210 const SwitchInst &SwInst = cast<SwitchInst>(U);
211 const unsigned SwCondValue = getOrCreateVReg(*SwInst.
getCondition());
214 for (
auto &CaseIt : SwInst.
cases()) {
215 const unsigned CaseValueReg = getOrCreateVReg(*CaseIt.getCaseValue());
230 MIRBuilder.
setMBB(*FalseBB);
241 const LoadInst &LI = cast<LoadInst>(U);
246 assert(!LI.
isAtomic() &&
"only non-atomic loads are supported at the moment");
251 unsigned Res = getOrCreateVReg(LI);
258 getMemOpAlignment(LI)));
268 assert(!SI.
isAtomic() &&
"only non-atomic stores supported at the moment");
283 getMemOpAlignment(SI)));
287 bool IRTranslator::translateExtractValue(
const User &U,
298 for (
auto Idx : EVI->indices())
307 unsigned Res = getOrCreateVReg(U);
308 MIRBuilder.
buildExtract(Res, Offset, getOrCreateVReg(*Src));
313 bool IRTranslator::translateInsertValue(
const User &U,
324 for (
auto Idx : IVI->indices())
333 unsigned Res = getOrCreateVReg(U);
335 MIRBuilder.
buildInsert(Res, getOrCreateVReg(*Src), getOrCreateVReg(Inserted),
341 bool IRTranslator::translateSelect(
const User &U,
349 bool IRTranslator::translateBitCast(
const User &U,
352 unsigned &
Reg = ValToVReg[&U];
359 return translateCast(TargetOpcode::G_BITCAST, U, MIRBuilder);
362 bool IRTranslator::translateCast(
unsigned Opcode,
const User &U,
365 unsigned Res = getOrCreateVReg(U);
370 bool IRTranslator::translateGetElementPtr(
const User &U,
377 unsigned BaseReg = getOrCreateVReg(Op0);
385 const Value *Idx = GTI.getOperand();
386 if (
StructType *StTy = GTI.getStructTypeOrNull()) {
387 unsigned Field = cast<Constant>(Idx)->getUniqueInteger().getZExtValue();
395 if (
const auto *CI = dyn_cast<ConstantInt>(Idx)) {
396 Offset += ElementSize * CI->getSExtValue();
404 MIRBuilder.
buildGEP(NewBaseReg, BaseReg, OffsetReg);
406 BaseReg = NewBaseReg;
414 unsigned IdxReg = getOrCreateVReg(*Idx);
415 if (MRI->
getType(IdxReg) != OffsetTy) {
422 MIRBuilder.
buildMul(OffsetReg, ElementSizeReg, IdxReg);
425 MIRBuilder.
buildGEP(NewBaseReg, BaseReg, OffsetReg);
426 BaseReg = NewBaseReg;
433 MIRBuilder.
buildGEP(getOrCreateVReg(U), BaseReg, OffsetReg);
437 MIRBuilder.
buildCopy(getOrCreateVReg(U), BaseReg);
441 bool IRTranslator::translateMemcpy(
const CallInst &CI,
452 for (
int i = 0;
i < 3; ++
i) {
454 Args.
emplace_back(getOrCreateVReg(*Arg), Arg->getType());
459 return CLI->
lowerCall(MIRBuilder, Callee,
463 void IRTranslator::getStackGuard(
unsigned DstReg,
465 auto MIB = MIRBuilder.
buildInstr(TargetOpcode::LOAD_STACK_GUARD);
480 MIB.setMemRefs(MemRefs, MemRefs + 1);
483 bool IRTranslator::translateOverflowIntrinsic(
const CallInst &CI,
unsigned Op,
487 unsigned Width = Ty.getSizeInBits();
496 if (Op == TargetOpcode::G_UADDE || Op == TargetOpcode::G_USUBE) {
502 MIRBuilder.
buildSequence(getOrCreateVReg(CI), Res, 0, Overflow, Width);
511 case Intrinsic::dbg_declare:
512 case Intrinsic::dbg_value:
517 case Intrinsic::uadd_with_overflow:
518 return translateOverflowIntrinsic(CI, TargetOpcode::G_UADDE, MIRBuilder);
519 case Intrinsic::sadd_with_overflow:
520 return translateOverflowIntrinsic(CI, TargetOpcode::G_SADDO, MIRBuilder);
521 case Intrinsic::usub_with_overflow:
522 return translateOverflowIntrinsic(CI, TargetOpcode::G_USUBE, MIRBuilder);
523 case Intrinsic::ssub_with_overflow:
524 return translateOverflowIntrinsic(CI, TargetOpcode::G_SSUBO, MIRBuilder);
525 case Intrinsic::umul_with_overflow:
526 return translateOverflowIntrinsic(CI, TargetOpcode::G_UMULO, MIRBuilder);
527 case Intrinsic::smul_with_overflow:
528 return translateOverflowIntrinsic(CI, TargetOpcode::G_SMULO, MIRBuilder);
529 case Intrinsic::memcpy:
530 return translateMemcpy(CI, MIRBuilder);
531 case Intrinsic::eh_typeid_for: {
533 unsigned Reg = getOrCreateVReg(CI);
538 case Intrinsic::objectsize: {
545 case Intrinsic::stackguard:
546 getStackGuard(getOrCreateVReg(CI), MIRBuilder);
548 case Intrinsic::stackprotector: {
551 getStackGuard(GuardVal, MIRBuilder);
555 GuardVal, getOrCreateVReg(*Slot),
558 getOrCreateFrameIndex(*Slot)),
560 PtrTy.getSizeInBits() / 8, 8));
568 const CallInst &CI = cast<CallInst>(U);
578 return CLI->
lowerCall(MIRBuilder, CI, Res, Args, [&]() {
589 if (translateKnownIntrinsic(CI, ID, MIRBuilder))
598 MIB.
addImm(CI->getSExtValue());
600 MIB.
addUse(getOrCreateVReg(*Arg));
605 bool IRTranslator::translateInvoke(
const User &U,
615 if (isa<InlineAsm>(Callee))
619 if (Fn && Fn->isIntrinsic())
627 if (!isa<LandingPadInst>(EHPadBB->
front()))
633 MCSymbol *BeginSymbol = Context.createTempSymbol();
639 Args.
emplace_back(getOrCreateVReg(*Arg), Arg->getType());
645 MCSymbol *EndSymbol = Context.createTempSymbol();
650 &ReturnMBB = getOrCreateBB(*ReturnBB);
651 MF->
addInvoke(&EHPadMBB, BeginSymbol, EndSymbol);
658 bool IRTranslator::translateLandingPad(
const User &U,
671 if (TLI.getExceptionPointerRegister(PersonalityFn) == 0 &&
672 TLI.getExceptionSelectorRegister(PersonalityFn) == 0)
691 if (
unsigned Reg = TLI.getExceptionPointerRegister(PersonalityFn)) {
698 if (
unsigned Reg = TLI.getExceptionSelectorRegister(PersonalityFn)) {
705 MIRBuilder.
buildSequence(getOrCreateVReg(LP), Regs, Offsets);
709 bool IRTranslator::translateStaticAlloca(
const AllocaInst &AI,
715 unsigned Res = getOrCreateVReg(AI);
716 int FI = getOrCreateFrameIndex(AI);
722 const PHINode &PI = cast<PHINode>(U);
723 auto MIB = MIRBuilder.
buildInstr(TargetOpcode::PHI);
724 MIB.
addDef(getOrCreateVReg(PI));
726 PendingPHIs.emplace_back(&PI, MIB.getInstr());
730 void IRTranslator::finishPendingPhis() {
731 for (std::pair<const PHINode *, MachineInstr *> &Phi : PendingPHIs) {
741 "I appear to have misunderstood Machine PHIs");
748 bool IRTranslator::translate(
const Instruction &Inst) {
751 #define HANDLE_INST(NUM, OPCODE, CLASS) \
752 case Instruction::OPCODE: return translate##OPCODE(Inst, CurBuilder);
753 #include "llvm/IR/Instruction.def"
761 bool IRTranslator::translate(
const Constant &
C,
unsigned Reg) {
762 if (
auto CI = dyn_cast<ConstantInt>(&C))
764 else if (
auto CF = dyn_cast<ConstantFP>(&C))
766 else if (isa<UndefValue>(C))
768 else if (isa<ConstantPointerNull>(C))
770 else if (
auto GV = dyn_cast<GlobalValue>(&C))
772 else if (
auto CE = dyn_cast<ConstantExpr>(&C)) {
773 switch(
CE->getOpcode()) {
774 #define HANDLE_INST(NUM, OPCODE, CLASS) \
775 case Instruction::OPCODE: return translate##OPCODE(*CE, EntryBuilder);
776 #include "llvm/IR/Instruction.def"
790 void IRTranslator::finalizeFunction() {
795 FrameIndices.clear();
805 CurBuilder.
setMF(*MF);
806 EntryBuilder.
setMF(*MF);
809 TPC = &getAnalysis<TargetPassConfig>();
811 assert(PendingPHIs.empty() &&
"stale PHIs");
817 EntryBB->addSuccessor(&getOrCreateBB(F.
front()));
818 EntryBuilder.
setMBB(*EntryBB);
823 VRegArgs.
push_back(getOrCreateVReg(Arg));
843 Succeeded &= translate(Inst);
864 assert(EntryBB->succ_size() == 1 &&
865 "Custom BB used for lowering should have only one successor");
868 assert(NewEntryBB.pred_size() == 1 &&
869 "LLVM-IR entry block has a predecessor!?");
872 NewEntryBB.splice(NewEntryBB.begin(), EntryBB, EntryBB->begin(),
877 NewEntryBB.addLiveIn(LiveIn);
878 NewEntryBB.sortUniqueLiveIns();
881 EntryBB->removeSuccessor(&NewEntryBB);
885 "New entry wasn't next in the list of basic block!");
virtual bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val, unsigned VReg) const
This hook must be implemented to lower outgoing return values, described by Val, into the specified v...
MachineBasicBlock & getMBB()
Getter for the basic block we currently build.
void initializeIRTranslatorPass(PassRegistry &)
BasicBlock * getSuccessor(unsigned i) const
Return a value (possibly void), from a function.
Value * getValueOperand()
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
void push_back(const T &Elt)
This class is the base class for the comparison instructions.
static IntegerType * getInt1Ty(LLVMContext &C)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
LLVM Argument representation.
MachineInstrBuilder buildGEP(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_GEP Op0, Op1.
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad. Returns the label ID for the landing pad entry.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB)
Extract the exception handling information from the landingpad instruction and add them to the specif...
unsigned getNumOperands() const
This class represents a function call, abstracting a target machine's calling convention.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
void setDebugLoc(const DebugLoc &DL)
Set the debug location to DL for all the next build instructions.
gep_type_iterator gep_type_end(const User *GEP)
iterator_range< op_iterator > arg_operands()
Iteration adapter for range-for loops.
bool isTokenTy() const
Return true if this is 'token'.
const Instruction & front() const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
An instruction for reading from memory.
virtual const CallLowering * getCallLowering() const
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
unsigned createGenericVirtualRegister(LLT Ty)
Create and return a new generic virtual register with low-level type Ty.
GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
MachineInstrBuilder buildSelect(unsigned Res, unsigned Tst, unsigned Op0, unsigned Op1)
Build and insert a Res = G_SELECT Tst, Op0, Op1.
MachineInstrBuilder buildFCmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_FCMP PredOp0, Op1.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
MachineInstrBuilder buildStore(unsigned Val, unsigned Addr, MachineMemOperand &MMO)
Build and insert G_STORE Val, Addr, MMO.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isUnconditional() const
A description of a memory reference used in the backend.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
struct fuzzer::@269 Flags
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
unsigned getPointerABIAlignment(unsigned AS=0) const
Layout pointer alignment FIXME: The defaults need to be removed once all of the backends/clients are ...
Class to represent struct types.
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
const MachineFunctionProperties & getProperties() const
Get the function properties.
void freezeReservedRegs(const MachineFunction &)
freezeReservedRegs - Called by the register allocator to freeze the set of reserved registers before ...
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
MachineInstrBuilder buildFConstant(unsigned Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Reg
All possible values of the reg field in the ModR/M byte.
TypeID
Definitions of all of the base types for the Type system.
The memory access is dereferenceable (i.e., doesn't trap).
virtual bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
Windows NT (Windows on ARM)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Target-Independent Code Generator Pass Configuration Options.
MachineInstrBuilder buildExtract(ArrayRef< unsigned > Results, ArrayRef< uint64_t > Indices, unsigned Src)
Build and insert `Res0<def>, ...
Context object for machine code objects.
const MachineBasicBlock & front() const
BasicBlock * getSuccessor(unsigned i) const
An instruction for storing to memory.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MCContext & getContext() const
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
unsigned getNumIncomingValues() const
Return the number of incoming edges.
uint64_t getElementOffset(unsigned Idx) const
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
The memory access is volatile.
MachineInstrBuilder buildBr(MachineBasicBlock &BB)
Build and insert G_BR Dest.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
IRTranslator LLVM IR false
unsigned const MachineRegisterInfo * MRI
LLVM Basic Block Representation.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
The instances of the Type class are immutable: once they are created, they are never changed...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Conditional or Unconditional Branch instruction.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
bool isVectorTy() const
True if this is an instance of VectorType.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
This is an important base class in LLVM.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
MachineInstrBuilder buildIntrinsic(Intrinsic::ID ID, unsigned Res, bool HasSideEffects)
Build and insert either a G_INTRINSIC (if HasSideEffects is false) or G_INTRINSIC_W_SIDE_EFFECTS inst...
Helper class to build MachineInstr.
bool isIntPredicate() const
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Represent the analysis usage information of a pass.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
MachineInstrBuilder buildICmp(CmpInst::Predicate Pred, unsigned Res, unsigned Op0, unsigned Op1)
Build and insert a Res = G_ICMP Pred, Op0, Op1.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned char TargetFlags=0)
bool doesNotAccessMemory() const
Determine if the call does not access memory.
Value * getOperand(unsigned i) const
int64_t getIndexedOffsetInType(Type *ElemTy, ArrayRef< Value * > Indices) const
Returns the offset from the beginning of the type for the specified indices.
Value * getPointerOperand()
void remove(iterator MBBI)
Predicate getPredicate() const
Return the predicate for this instruction.
void setMF(MachineFunction &)
Setters for the insertion point.
succ_iterator succ_begin()
MachineInstrBuilder buildSExtOrTrunc(unsigned Res, unsigned Op)
Build and insert Res<def> = G_SEXT Op, Res = G_TRUNC Op, or Res = COPY Op depending on the differing ...
LLVMContext & getContext() const
All values hold a context through their type.
This class contains a discriminated union of information about pointers in memory operands...
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
MachineInstrBuilder buildFrameIndex(unsigned Res, int Idx)
Build and insert Res<def> = G_FRAME_INDEX Idx.
The memory access writes data.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
This is the shared class of boolean and integer constants.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
INITIALIZE_PASS_BEGIN(IRTranslator, DEBUG_TYPE,"IRTranslator LLVM IR -> MI", false, false) INITIALIZE_PASS_END(IRTranslator
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size...
Type * getType() const
All values are typed, get the type of this value.
MachineInstrBuilder buildCopy(unsigned Res, unsigned Op)
Build and insert Res<def> = COPY Op.
virtual const TargetLowering * getTargetLowering() const
bool isVolatile() const
Return true if this is a load from a volatile memory location.
virtual bool lowerCall(MachineIRBuilder &MIRBuilder, const MachineOperand &Callee, const ArgInfo &OrigRet, ArrayRef< ArgInfo > OrigArgs) const
This hook must be implemented to lower the given call instruction, including argument and return valu...
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SynchronizationScope SynchScope=CrossThread, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
void setHasAddressTaken()
Set this block to reflect that it potentially is the target of an indirect branch.
Value * getCondition() const
MachineFunctionProperties & set(Property P)
The memory access reads data.
MachineInstrBuilder buildSequence(unsigned Res, ArrayRef< unsigned > Ops, ArrayRef< uint64_t > Indices)
Build and insert Res<def> = G_SEQUENCE Op0, Idx0...
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
MachineInstrBuilder buildInsert(unsigned Res, unsigned Src, unsigned Op, unsigned Index, ArgTys...Args)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Value * getCondition() const
void emplace_back(ArgTypes &&...Args)
BasicBlock * getDefaultDest() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static IntegerType * getInt32Ty(LLVMContext &C)
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
virtual bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F, ArrayRef< unsigned > VRegs) const
This hook must be implemented to lower the incoming (formal) arguments, described by Args...
void setMBB(MachineBasicBlock &MBB)
Set the insertion point to the end of MBB.
MachineInstrBuilder buildConstant(unsigned Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
MachineInstrBuilder buildMul(unsigned Res, unsigned Op0, unsigned Op1)
Build and insert Res<def> = G_MUL Op0, Op1.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Pair of physical register and lane mask.
The memory access always returns the same value (or traps).
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
IRTranslator LLVM IR static false void reportTranslationError(const Value &V, const Twine &Message)
iterator_range< op_iterator > arg_operands()
Iteration adapter for range-for loops.
This file declares the IRTranslator pass.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
A raw_ostream that writes to an std::string.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space (defaulting to 0).
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
This file describes how to lower LLVM calls to machine code calls.
void push_back(MachineBasicBlock *MBB)
MachineInstrBuilder buildLoad(unsigned Res, unsigned Addr, MachineMemOperand &MMO)
Build and insert Res<def> = G_LOAD Addr, MMO.
const Value * getArraySize() const
Get the number of elements allocated.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
MachineInstrBuilder buildGlobalValue(unsigned Res, const GlobalValue *GV)
Build and insert Res<def> = G_GLOBAL_VALUE GV.
Value * getPointerOperand()
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
Statically lint checks LLVM IR
const BasicBlock * getParent() const
iterator_range< arg_iterator > args()
This file describes how to lower LLVM code to machine code.
bool isVoidTy() const
Return true if this is 'void'.
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.
gep_type_iterator gep_type_begin(const User *GEP)
MachineInstrBuilder buildBrCond(unsigned Tst, MachineBasicBlock &BB)
Build and insert G_BRCOND Tst, Dest.