llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
#include <emitter/riscv/riscvisel.h>
Public Member Functions | |
RISCVISel (const Target &target, llvm::RISCVTargetMachine &tm, llvm::TargetLibraryInfo &libInfo, const Prog &prog, llvm::CodeGenOpt::Level ol, bool shared) | |
![]() | |
llvm::MachineFunction * | operator[] (const Func *func) const |
Finds the MachineFunction attached to a function. | |
llvm::MCSymbol * | operator[] (const Inst *inst) const |
Finds the label attached to an instruction. | |
llvm::MachineBasicBlock * | operator[] (const Block *block) const |
Finds the MachineBasicBlock attached to a block. | |
const CamlFrame * | operator[] (llvm::MCSymbol *symbol) const |
Finds the frame attached to a symbol. | |
Static Public Attributes | |
static char | ID |
Additional Inherited Members | |
![]() | |
using | MVT = llvm::MVT |
using | EVT = llvm::EVT |
using | SDNode = llvm::SDNode |
using | SDValue = llvm::SDValue |
using | SDVTList = llvm::SDVTList |
using | SelectionDAG = llvm::SelectionDAG |
using | GlobalValue = llvm::GlobalValue |
using | RegParts = llvm::SmallVector< std::pair< llvm::Register, llvm::MVT >, 2 > |
using | ExportList = std::vector< std::pair< RegParts, SDValue > > |
using | FrameExports = std::vector< std::pair< ConstRef< Inst >, llvm::SDValue > > |
Vector of exported values from the frame. | |
![]() | |
ISel (char &ID, const Target &target, const Prog &prog, llvm::TargetLibraryInfo &libInfo, llvm::CodeGenOpt::Level ol) | |
Initialises the instruction selector. | |
void | Lower (const Inst *inst) |
Lowers an instruction. | |
virtual bool | Finalize (llvm::MachineFunction &MF) |
Finalize the lowering. | |
SDValue | LoadReg (Register reg) |
Lovers a register value. | |
llvm::SDValue | LowerGlobal (const Global &val, Type type) |
Lowers an offset reference to a global. | |
llvm::SDValue | LowerGlobal (const Global &val, int64_t offset, Type type) |
Lowers a global value. | |
void | LowerArgs (const CallLowering &lowering) |
Lowers all arguments. | |
std::pair< llvm::SDValue, llvm::SDValue > | LowerRets (llvm::SDValue chain, const CallLowering &lowering, const ReturnInst *ret, llvm::SmallVectorImpl< SDValue > &ops) |
Lower all return values. | |
std::pair< llvm::SDValue, llvm::SDValue > | LowerRaises (llvm::SDValue chain, const CallLowering &lowering, const RaiseInst *ret, llvm::SmallVectorImpl< llvm::Register > ®s, llvm::SDValue glue) |
Lower all return values. | |
void | LowerPad (const CallLowering &lowering, const LandingPadInst *inst) |
Lowers a landing pad. | |
SDValue | GetPrimitiveExportRoot () |
Flushes pending exports that are not OCaml values. | |
SDValue | GetValueExportRoot () |
Flushes pending exports which are OCaml values. | |
SDValue | GetExportRoot () |
Flushes all pending exports. | |
SDValue | GetExportRoot (const ExportList &exports) |
Export a set of values. | |
bool | HasPendingExports () |
Checks if there are any pending exports. | |
RegParts | ExportValue (SDValue value) |
Copies a value to a vreg to be exported later. | |
RegParts | AssignVReg (ConstRef< Inst > inst) |
Creates a register for an instruction's result. | |
SDValue | LowerInlineAsm (unsigned opcode, SDValue chain, const char *code, unsigned flags, llvm::ArrayRef< llvm::Register > inputs, llvm::ArrayRef< llvm::Register > clobbers, llvm::ArrayRef< llvm::Register > outputs, SDValue glue=SDValue()) |
Lower an inline asm sequence. | |
SDValue | LowerImm (const APInt &val, Type type) |
Lowers an immediate to a SDValue. | |
SDValue | LowerImm (const APFloat &val, Type type) |
Lowers an immediate to a SDValue. | |
SDValue | LowerConstant (ConstRef< Inst > inst) |
Returns a constant if the instruction introduces one. | |
SDValue | LowerExpr (const Expr &expr, Type type) |
Lowers an expression value. | |
SDValue | GetValue (ConstRef< Inst > inst) |
Looks up an existing value. | |
void | Export (ConstRef< Inst > inst, llvm::SDValue val) |
Exports a value. | |
llvm::ISD::CondCode | GetCond (Cond cc) |
Converts a condition code. | |
FrameExports | GetFrameExport (const Inst *frame) |
Get the relevant vars for a GC frame. | |
llvm::SDValue | LowerGCFrame (llvm::SDValue chain, llvm::SDValue glue, const CallSite *inst) |
Lower a GC frame. | |
ConstRef< Value > | GetMoveArg (ConstRef< MovInst > inst) |
Follow move arguments to a non-move instruction. | |
bool | IsExported (ConstRef< Inst > inst) |
Check if the value is exported from its defining block. | |
MVT | GetPointerType () const |
Return the pointer type. | |
virtual void | PrepareFunction (const Func &func, llvm::MachineFunction &MF) |
Prepare a function. | |
void | HandleSuccessorPHI (const Block *block) |
Handle PHI nodes in successor blocks. | |
void | CodeGenAndEmitDAG () |
Prepares the dag for instruction selection. | |
void | DoInstructionSelection () |
Creates a MachineBasicBlock with MachineInstrs. | |
void | Error (const Inst *i, const std::string_view &message) |
Report an error at an instruction. | |
void | Error (const Func *f, const std::string_view &message) |
Report an error in a function. | |
void | LowerVAStart (const VaStartInst *inst) |
Lowers a vararg frame setup instruction. | |
void | LowerCall (const CallInst *inst) |
Lowers a call instructions. | |
void | LowerTailCall (const TailCallInst *inst) |
Lowers a tail call instruction. | |
void | LowerInvoke (const InvokeInst *inst) |
Lowers an invoke instruction. | |
void | LowerFrameCall (const FrameCallInst *inst) |
Lowers a frame call instruction. | |
void | LowerBinary (const Inst *inst, unsigned op) |
Lowers a binary instruction. | |
void | LowerBinary (const Inst *inst, unsigned sop, unsigned fop) |
Lowers a binary integer or float operation. | |
void | LowerShift (const Inst *inst, unsigned op) |
Lowers a shift instruction. | |
void | LowerUnary (const UnaryInst *inst, unsigned opcode) |
Lowers a unary instruction. | |
void | LowerJUMP_COND (const JumpCondInst *inst) |
Lowers a conditional jump true instruction. | |
void | LowerJUMP (const JumpInst *inst) |
Lowers a jump instruction. | |
void | LowerSwitch (const SwitchInst *inst) |
Lowers a switch. | |
void | LowerLD (const LoadInst *inst) |
Lowers a load. | |
void | LowerST (const StoreInst *inst) |
Lowers a store. | |
void | LowerFrame (const FrameInst *inst) |
Lowers a frame instruction. | |
void | LowerCmp (const CmpInst *inst) |
Lowers a comparison instruction. | |
void | LowerTrap (const TrapInst *inst) |
Lowers a trap instruction. | |
void | LowerDebugTrap (const DebugTrapInst *inst) |
Lowers a debug trap instruction. | |
void | LowerMov (const MovInst *inst) |
Lowers a mov instruction. | |
void | LowerSExt (const SExtInst *inst) |
Lowers a sign extend instruction. | |
void | LowerZExt (const ZExtInst *inst) |
Lowers a zero extend instruction. | |
void | LowerFExt (const FExtInst *inst) |
Lowers a float extend instruction. | |
void | LowerXExt (const XExtInst *inst) |
Lowers a any extend instruction. | |
void | LowerTrunc (const TruncInst *inst) |
Lowers a truncate instruction. | |
void | LowerAlloca (const AllocaInst *inst) |
Lowers an alloca instruction. | |
void | LowerSelect (const SelectInst *inst) |
Lowers a select instruction. | |
void | LowerUndef (const UndefInst *inst) |
Lowers an undefined instruction. | |
void | LowerALUO (const BinaryInst *inst, unsigned op) |
Lowers an overflow check instruction. | |
void | LowerGet (const GetInst *inst) |
Lowers a fixed register get instruction. | |
void | LowerBitCast (const BitCastInst *inst) |
Lowers a bit cast instruction. | |
std::pair< bool, llvm::CallingConv::ID > | GetCallingConv (const Func *caller, const CallSite *call) |
Find the calling convention of a call. | |
SDValue | LowerCallArguments (SDValue chain, const CallSite *call, CallLowering &ci, llvm::SmallVectorImpl< std::pair< unsigned, SDValue >> ®s) |
Lower the arguments to a call. | |
std::pair< SDValue, SDValue > | LowerReturns (SDValue chain, SDValue inFlag, const CallSite *call, llvm::SmallVectorImpl< CallLowering::RetLoc > &returns, llvm::SmallVectorImpl< SDValue > ®s, llvm::SmallVectorImpl< std::pair< ConstRef< Inst >, SDValue >> &values) |
Lower values returned from a call. | |
![]() | |
const Target & | target_ |
Reference to the target. | |
const Prog & | prog_ |
Program to lower. | |
llvm::TargetLibraryInfo & | libInfo_ |
Target library info. | |
llvm::DebugLoc | DL_ |
Dummy debug location. | |
llvm::SDLoc | SDL_ |
Dummy SelectionDAG debug location. | |
llvm::Module * | M_ |
Current module. | |
llvm::Type * | voidTy_ |
Void type. | |
llvm::Type * | i8PtrTy_ |
Void pointer type. | |
llvm::FunctionType * | funcTy_ |
Dummy function type. | |
llvm::CodeGenOpt::Level | ol_ |
Chosen optimisation level. | |
const Func * | func_ |
Current function. | |
llvm::Function * | F_ |
Current LLVM function. | |
llvm::MachineBasicBlock * | MBB_ |
Current basic block. | |
llvm::MachineBasicBlock::iterator | insert_ |
Current insertion point. | |
std::unique_ptr< LiveVariables > | lva_ |
Per-function live variable info. | |
std::unordered_map< ConstRef< Inst >, llvm::SDValue > | values_ |
Mapping from nodes to values. | |
std::unordered_map< ConstRef< Inst >, RegParts > | regs_ |
Mapping from nodes to registers. | |
llvm::DenseMap< unsigned, unsigned > | stackIndices_ |
Mapping from stack_object indices to llvm stack objects. | |
int | frameIndex_ |
Frame start index, if necessary. | |
std::vector< std::pair< RegParts, llvm::SDValue > > | pendingPrimValues_ |
Pending primitives to be exported. | |
std::unordered_map< ConstRef< Inst >, RegParts > | pendingPrimInsts_ |
Pending primitive instructions to be exported. | |
std::unordered_map< ConstRef< Inst >, RegParts > | pendingValueInsts_ |
Pending value-producing instructions to be exported. | |
![]() | |
std::unordered_map< const Func *, llvm::MachineFunction * > | funcs_ |
Mapping from functions to MachineFunctions. | |
std::unordered_map< const Block *, llvm::MachineBasicBlock * > | mbbs_ |
Mapping from blocks to machine blocks. | |
std::unordered_map< const Block *, llvm::BasicBlock * > | bbs_ |
Mapping from blocks to basic blocks. | |
std::unordered_map< const Inst *, llvm::MCSymbol * > | labels_ |
Labels of annotated instructions. | |
std::unordered_map< llvm::MCSymbol *, const CamlFrame * > | frames_ |
Mapping from labels to instructions. | |
Custom pass to generate MIR from LLIR instead of LLVM IR.