48#define DEBUG_TYPE "asm-printer"
51 "Number of RISC-V Compressed instructions emitted");
67 std::unique_ptr<MCStreamer> Streamer)
101 typedef std::tuple<unsigned, uint32_t> HwasanMemaccessTuple;
102 std::map<HwasanMemaccessTuple, MCSymbol *> HwasanMemaccessSymbols;
105 void EmitHwasanMemaccessSymbols(
Module &M);
114 bool emitDirectiveOptionArch();
116 void emitNoteGnuProperty(
const Module &M);
135 unsigned NOPBytes = STI->hasStdExtZca() ? 2 : 4;
139 MCSymbol *MILabel = Ctx.createTempSymbol();
143 assert(NumNOPBytes % NOPBytes == 0 &&
144 "Invalid number of NOP bytes requested!");
150 while (NumNOPBytes > 0) {
151 if (MII ==
MBB.
end() || MII->isCall() ||
152 MII->getOpcode() == RISCV::DBG_VALUE ||
153 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
154 MII->getOpcode() == TargetOpcode::STACKMAP)
161 emitNops(NumNOPBytes / NOPBytes);
168 unsigned NOPBytes = STI->hasStdExtZca() ? 2 : 4;
171 MCSymbol *MILabel = Ctx.createTempSymbol();
178 unsigned EncodedBytes = 0;
180 if (CalleeMO.
isImm()) {
183 assert((CallTarget & 0xFFFF'FFFF'FFFF) == CallTarget &&
184 "High 16 bits of call target should be zero.");
188 for (
MCInst &Inst : Seq) {
189 bool Compressed = EmitToStreamer(OutStreamer, Inst);
190 EncodedBytes += Compressed ? 2 : 4;
192 bool Compressed = EmitToStreamer(OutStreamer,
MCInstBuilder(RISCV::JALR)
196 EncodedBytes += Compressed ? 2 : 4;
200 lowerOperand(CalleeMO, CallTargetMCOp);
201 EmitToStreamer(OutStreamer,
207 unsigned NumBytes = Opers.getNumPatchBytes();
208 assert(NumBytes >= EncodedBytes &&
209 "Patchpoint can't request size less than the length of a call.");
210 assert((NumBytes - EncodedBytes) % NOPBytes == 0 &&
211 "Invalid number of NOP bytes requested!");
212 emitNops((NumBytes - EncodedBytes) / NOPBytes);
217 unsigned NOPBytes = STI->hasStdExtZca() ? 2 : 4;
220 if (
unsigned PatchBytes = SOpers.getNumPatchBytes()) {
221 assert(PatchBytes % NOPBytes == 0 &&
222 "Invalid number of NOP bytes requested!");
223 emitNops(PatchBytes / NOPBytes);
228 switch (CallTarget.
getType()) {
231 lowerOperand(CallTarget, CallTargetMCOp);
256 MCSymbol *MILabel = Ctx.createTempSymbol();
266 ++RISCVNumInstrsCompressed;
273#include "RISCVGenMCPseudoLowering.inc"
278 if (!STI->hasStdExtZihintntl())
281 if (
MI->memoperands_empty())
288 unsigned NontemporalMode = 0;
290 NontemporalMode += 0b1;
292 NontemporalMode += 0b10;
295 if (STI->hasStdExtZca())
304 EmitToStreamer(*OutStreamer, Hint);
308 RISCV_MC::verifyInstructionPredicates(
MI->getOpcode(), STI->getFeatureBits());
313 if (
MCInst OutInst; lowerPseudoInstExpansion(
MI, OutInst)) {
314 EmitToStreamer(*OutStreamer, OutInst);
318 switch (
MI->getOpcode()) {
319 case RISCV::HWASAN_CHECK_MEMACCESS_SHORTGRANULES:
320 LowerHWASAN_CHECK_MEMACCESS(*
MI);
322 case RISCV::KCFI_CHECK:
323 LowerKCFI_CHECK(*
MI);
325 case TargetOpcode::STACKMAP:
326 return LowerSTACKMAP(*OutStreamer, SM, *
MI);
327 case TargetOpcode::PATCHPOINT:
328 return LowerPATCHPOINT(*OutStreamer, SM, *
MI);
329 case TargetOpcode::STATEPOINT:
330 return LowerSTATEPOINT(*OutStreamer, SM, *
MI);
331 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
334 const Function &
F =
MI->getParent()->getParent()->getFunction();
335 if (
F.hasFnAttribute(
"patchable-function-entry"))
338 LowerPATCHABLE_FUNCTION_ENTER(
MI);
341 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
342 LowerPATCHABLE_FUNCTION_EXIT(
MI);
344 case TargetOpcode::PATCHABLE_TAIL_CALL:
345 LowerPATCHABLE_TAIL_CALL(
MI);
350 if (!lowerToMCInst(
MI, OutInst))
351 EmitToStreamer(*OutStreamer, OutInst);
354bool RISCVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
361 if (ExtraCode && ExtraCode[0]) {
362 if (ExtraCode[1] != 0)
365 switch (ExtraCode[0]) {
396 PrintSymbolOperand(MO,
OS);
410bool RISCVAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
412 const char *ExtraCode,
418 assert(
MI->getNumOperands() > OpNo + 1 &&
"Expected additional operand");
422 if (!AddrReg.
isReg())
429 if (!lowerOperand(
Offset, MCO))
438 MMI->getContext().registerInlineAsmLabel(
Offset.getMCSymbol());
439 if (
Offset.isBlockAddress()) {
442 MMI->getContext().registerInlineAsmLabel(
Sym);
449bool RISCVAsmPrinter::emitDirectiveOptionArch() {
455 if (STI->hasFeature(Feature.Value) == MCSTI.
hasFeature(Feature.Value))
461 auto Delta = STI->hasFeature(Feature.Value) ? RISCVOptionArchArgType::Plus
462 : RISCVOptionArchArgType::Minus;
465 if (!NeedEmitStdOptionArgs.
empty()) {
479 bool EmittedOptionArch = emitDirectiveOptionArch();
481 SetupMachineFunction(MF);
487 if (EmittedOptionArch)
488 RTS.emitDirectiveOptionPop();
492void RISCVAsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
const MachineInstr *
MI) {
493 emitSled(
MI, SledKind::FUNCTION_ENTER);
496void RISCVAsmPrinter::LowerPATCHABLE_FUNCTION_EXIT(
const MachineInstr *
MI) {
497 emitSled(
MI, SledKind::FUNCTION_EXIT);
500void RISCVAsmPrinter::LowerPATCHABLE_TAIL_CALL(
const MachineInstr *
MI) {
501 emitSled(
MI, SledKind::TAIL_CALL);
504void RISCVAsmPrinter::emitSled(
const MachineInstr *
MI, SledKind Kind) {
519 const uint8_t NoopsInSledCount = STI->is64Bit() ? 33 : 21;
522 auto CurSled = OutContext.createTempSymbol(
"xray_sled_",
true);
524 auto Target = OutContext.createTempSymbol();
532 MCInstBuilder(RISCV::JAL).addReg(RISCV::X0).addExpr(TargetExpr));
535 for (int8_t
I = 0;
I < NoopsInSledCount; ++
I)
542 recordSled(CurSled, *
MI, Kind, 2);
545void RISCVAsmPrinter::emitStartOfAsmFile(
Module &M) {
548 if (
const MDString *ModuleTargetABI =
549 dyn_cast_or_null<MDString>(
M.getModuleFlag(
"target-abi")))
555 if (
auto *MD = dyn_cast_or_null<MDNode>(
M.getModuleFlag(
"riscv-isa"))) {
556 for (
auto &ISA : MD->operands()) {
557 if (
auto *ISAString = dyn_cast_or_null<MDString>(ISA)) {
559 ISAString->getString(),
true,
564 if (ISAInfo->hasExtension(Feature.Key) &&
575 if (
TM.getTargetTriple().isOSBinFormatELF())
576 emitAttributes(SubtargetInfo);
579void RISCVAsmPrinter::emitEndOfAsmFile(
Module &M) {
583 if (
TM.getTargetTriple().isOSBinFormatELF()) {
585 emitNoteGnuProperty(M);
587 EmitHwasanMemaccessSymbols(M);
590void RISCVAsmPrinter::emitAttributes(
const MCSubtargetInfo &SubtargetInfo) {
599void RISCVAsmPrinter::emitFunctionEntryLabel() {
601 if (RMFI->isVectorCall()) {
618void RISCVAsmPrinter::LowerHWASAN_CHECK_MEMACCESS(
const MachineInstr &
MI) {
620 uint32_t AccessInfo =
MI.getOperand(1).getImm();
622 HwasanMemaccessSymbols[HwasanMemaccessTuple(Reg, AccessInfo)];
625 if (!
TM.getTargetTriple().isOSBinFormatELF())
628 std::string SymName =
"__hwasan_check_x" + utostr(Reg - RISCV::X0) +
"_" +
629 utostr(AccessInfo) +
"_short";
630 Sym = OutContext.getOrCreateSymbol(SymName);
635 EmitToStreamer(*OutStreamer,
MCInstBuilder(RISCV::PseudoCALL).addExpr(Expr));
640 assert(std::next(
MI.getIterator())->isCall() &&
641 "KCFI_CHECK not followed by a call instruction");
642 assert(std::next(
MI.getIterator())->getOperand(0).getReg() == AddrReg &&
643 "KCFI_CHECK call target doesn't match call operand");
650 unsigned ScratchRegs[] = {RISCV::X6, RISCV::X7};
651 unsigned NextReg = RISCV::X28;
652 auto isRegAvailable = [&](
unsigned Reg) {
653 return Reg != AddrReg && !STI->isRegisterReservedByUser(Reg);
655 for (
auto &Reg : ScratchRegs) {
656 if (isRegAvailable(Reg))
658 while (!isRegAvailable(NextReg))
661 if (Reg > RISCV::X31)
665 if (AddrReg == RISCV::X0) {
669 .addReg(ScratchRegs[0])
675 int NopSize = STI->hasStdExtZca() ? 2 : 4;
676 int64_t PrefixNops = 0;
679 .getFnAttribute(
"patchable-function-prefix")
681 .getAsInteger(10, PrefixNops);
685 .addReg(ScratchRegs[0])
687 .addImm(-(PrefixNops * NopSize + 4)));
691 const int64_t
Type =
MI.getOperand(1).getImm();
692 const int64_t Hi20 = ((
Type + 0x800) >> 12) & 0xFFFFF;
693 const int64_t Lo12 = SignExtend64<12>(
Type);
697 MCInstBuilder(RISCV::LUI).addReg(ScratchRegs[1]).addImm(Hi20));
699 if (Lo12 || Hi20 == 0) {
700 EmitToStreamer(*OutStreamer,
711 EmitToStreamer(*OutStreamer,
713 .addReg(ScratchRegs[0])
714 .addReg(ScratchRegs[1])
720 emitKCFITrapEntry(*
MI.getMF(),
Trap);
724void RISCVAsmPrinter::EmitHwasanMemaccessSymbols(
Module &M) {
725 if (HwasanMemaccessSymbols.empty())
728 assert(
TM.getTargetTriple().isOSBinFormatELF());
735 OutContext.getOrCreateSymbol(
"__hwasan_tag_mismatch_v2");
745 ELF::R_RISCV_CALL_PLT, OutContext);
747 for (
auto &
P : HwasanMemaccessSymbols) {
748 unsigned Reg = std::get<0>(
P.first);
749 uint32_t AccessInfo = std::get<1>(
P.first);
767 MCInstBuilder(RISCV::SLLI).addReg(RISCV::X6).addReg(Reg).addImm(8),
769 EmitToStreamer(*OutStreamer,
776 EmitToStreamer(*OutStreamer,
784 MCInstBuilder(RISCV::LBU).addReg(RISCV::X6).addReg(RISCV::X6).addImm(0),
789 MCInstBuilder(RISCV::SRLI).addReg(RISCV::X7).addReg(Reg).addImm(56),
791 MCSymbol *HandleMismatchOrPartialSym = OutContext.createTempSymbol();
793 EmitToStreamer(*OutStreamer,
798 HandleMismatchOrPartialSym, OutContext)),
800 MCSymbol *ReturnSym = OutContext.createTempSymbol();
802 EmitToStreamer(*OutStreamer,
808 OutStreamer->
emitLabel(HandleMismatchOrPartialSym);
810 EmitToStreamer(*OutStreamer,
816 MCSymbol *HandleMismatchSym = OutContext.createTempSymbol();
827 MCInstBuilder(RISCV::ANDI).addReg(RISCV::X28).addReg(Reg).addImm(0xF),
831 EmitToStreamer(*OutStreamer,
847 MCInstBuilder(RISCV::ORI).addReg(RISCV::X6).addReg(Reg).addImm(0xF),
851 MCInstBuilder(RISCV::LBU).addReg(RISCV::X6).addReg(RISCV::X6).addImm(0),
853 EmitToStreamer(*OutStreamer,
860 OutStreamer->
emitLabel(HandleMismatchSym);
897 EmitToStreamer(*OutStreamer,
905 EmitToStreamer(*OutStreamer,
912 EmitToStreamer(*OutStreamer,
922 MCInstBuilder(RISCV::SD).addReg(RISCV::X8).addReg(RISCV::X2).addImm(8 *
928 MCInstBuilder(RISCV::SD).addReg(RISCV::X1).addReg(RISCV::X2).addImm(1 *
931 if (Reg != RISCV::X10)
934 MCInstBuilder(RISCV::ADDI).addReg(RISCV::X10).addReg(Reg).addImm(0),
936 EmitToStreamer(*OutStreamer,
943 EmitToStreamer(*OutStreamer,
MCInstBuilder(RISCV::PseudoCALL).addExpr(Expr),
948void RISCVAsmPrinter::emitNoteGnuProperty(
const Module &M) {
949 if (
const Metadata *
const Flag =
M.getModuleFlag(
"cf-protection-return");
950 Flag && !mdconst::extract<ConstantInt>(Flag)->isZero()) {
969 Kind = ELF::R_RISCV_CALL_PLT;
975 Kind = ELF::R_RISCV_HI20;
981 Kind = ELF::R_RISCV_PCREL_HI20;
984 Kind = ELF::R_RISCV_GOT_HI20;
990 Kind = ELF::R_RISCV_TPREL_HI20;
993 Kind = ELF::R_RISCV_TPREL_ADD;
996 Kind = ELF::R_RISCV_TLS_GOT_HI20;
999 Kind = ELF::R_RISCV_TLS_GD_HI20;
1002 Kind = ELF::R_RISCV_TLSDESC_HI20;
1005 Kind = ELF::R_RISCV_TLSDESC_LOAD_LO12;
1008 Kind = ELF::R_RISCV_TLSDESC_ADD_LO12;
1011 Kind = ELF::R_RISCV_TLSDESC_CALL;
1074 RISCVVPseudosTable::getPseudoInfo(
MI->getOpcode());
1082 assert(
TRI &&
"TargetRegisterInfo expected");
1086 unsigned NumOps =
MI->getNumExplicitOperands();
1099 bool hasVLOutput = RISCVInstrInfo::isFaultOnlyFirstLoad(*
MI);
1100 for (
unsigned OpNo = 0; OpNo != NumOps; ++OpNo) {
1103 if (hasVLOutput && OpNo == 1)
1107 if (OpNo ==
MI->getNumExplicitDefs() && MO.
isReg() && MO.
isTied()) {
1109 "Expected tied to first def.");
1126 if (RISCV::VRM2RegClass.
contains(Reg) ||
1127 RISCV::VRM4RegClass.
contains(Reg) ||
1128 RISCV::VRM8RegClass.
contains(Reg)) {
1129 Reg =
TRI->getSubReg(Reg, RISCV::sub_vrm1_0);
1130 assert(Reg &&
"Subregister does not exist");
1131 }
else if (RISCV::FPR16RegClass.
contains(Reg)) {
1133 TRI->getMatchingSuperReg(Reg, RISCV::sub_16, &RISCV::FPR32RegClass);
1134 assert(Reg &&
"Subregister does not exist");
1135 }
else if (RISCV::FPR64RegClass.
contains(Reg)) {
1136 Reg =
TRI->getSubReg(Reg, RISCV::sub_32);
1137 assert(Reg &&
"Superregister does not exist");
1138 }
else if (RISCV::VRN2M1RegClass.
contains(Reg) ||
1139 RISCV::VRN2M2RegClass.
contains(Reg) ||
1140 RISCV::VRN2M4RegClass.
contains(Reg) ||
1141 RISCV::VRN3M1RegClass.
contains(Reg) ||
1142 RISCV::VRN3M2RegClass.
contains(Reg) ||
1143 RISCV::VRN4M1RegClass.
contains(Reg) ||
1144 RISCV::VRN4M2RegClass.
contains(Reg) ||
1145 RISCV::VRN5M1RegClass.
contains(Reg) ||
1146 RISCV::VRN6M1RegClass.
contains(Reg) ||
1147 RISCV::VRN7M1RegClass.
contains(Reg) ||
1148 RISCV::VRN8M1RegClass.
contains(Reg)) {
1149 Reg =
TRI->getSubReg(Reg, RISCV::sub_vrm1_0);
1150 assert(Reg &&
"Subregister does not exist");
1168 RISCV::VMV0RegClassID &&
1169 "Expected only mask operand to be missing");
1185 if (lowerOperand(MO, MCOp))
1190 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
1191 const Function &
F =
MI->getParent()->getParent()->getFunction();
1192 if (
F.hasFnAttribute(
"patchable-function-entry")) {
1194 if (
F.getFnAttribute(
"patchable-function-entry")
1196 .getAsInteger(10, Num))
1207void RISCVAsmPrinter::emitMachineConstantPoolValue(
1212 if (RCPV->isGlobalValue()) {
1213 auto *GV = RCPV->getGlobalValue();
1214 MCSym = getSymbol(GV);
1216 assert(RCPV->isExtSymbol() &&
"unrecognized constant pool type");
1217 auto Sym = RCPV->getSymbol();
1218 MCSym = GetExternalSymbolSymbol(
Sym);
1222 uint64_t Size = getDataLayout().getTypeAllocSize(RCPV->getType());
1226char RISCVAsmPrinter::ID = 0;
1228INITIALIZE_PASS(RISCVAsmPrinter,
"riscv-asm-printer",
"RISC-V Assembly Printer",
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static MCDisassembler::DecodeStatus addOperand(MCInst &Inst, const MCOperand &Opnd)
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register const TargetRegisterInfo * TRI
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool lowerRISCVVMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, const RISCVSubtarget *STI)
static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym, const AsmPrinter &AP)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmPrinter()
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This class is intended to be used as a driving class for all asm writers.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
virtual void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
virtual void emitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
MCContext & OutContext
This is the context for the output file that we are streaming.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
The address of a basic block.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
MCInstBuilder & addReg(MCRegister Reg)
Add a new register operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specified operand constraint if it is present.
Instances of this class represent operands of the MCInst class.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
const MCExpr * getExpr() const
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Streaming machine code generation interface.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
MCContext & getContext() const
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
MCTargetStreamer * getTargetStreamer()
virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
FeatureBitset ToggleFeature(uint64_t FB)
Toggle a feature and return the re-computed feature bits.
Represent a reference to a symbol from inside an expression.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Abstract base class for all machine specific constantpool value subclasses.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
A description of a memory reference used in the backend.
bool isNonTemporal() const
Flags getFlags() const
Return the raw flags of the source value,.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
const BlockAddress * getBlockAddress() const
unsigned getTargetFlags() const
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
MCSymbol * getMCSymbol() const
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_MCSymbol
MCSymbol reference (for debug/eh info)
@ MO_GlobalAddress
Address of a global value.
@ MO_RegisterMask
Mask of preserved registers.
@ MO_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
int64_t getOffset() const
Return the offset from the symbol in this operand.
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
A Module instance is used to store all the information related to an LLVM module.
This class represents success/failure for parsing-like operations that find it important to chain tog...
Pass interface - Implemented by all 'passes'.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
MI-level patchpoint operands.
A RISCV-specific constant pool value.
static LLVM_ABI bool isSupportedExtensionFeature(StringRef Ext)
static LLVM_ABI llvm::Expected< std::unique_ptr< RISCVISAInfo > > parseArchString(StringRef Arch, bool EnableExperimentalExtension, bool ExperimentalExtensionVersionCheck=true)
Parse RISC-V ISA info from arch string.
static const char * getRegisterName(MCRegister Reg)
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
const RISCVRegisterInfo * getRegisterInfo() const override
const RISCVInstrInfo * getInstrInfo() const override
void emitNoteGnuPropertySection(const uint32_t Feature1And)
virtual void emitDirectiveVariantCC(MCSymbol &Symbol)
void emitTargetAttributes(const MCSubtargetInfo &STI, bool EmitStackAlign)
void setFlagsFromFeatures(const MCSubtargetInfo &STI)
void setTargetABI(RISCVABI::ABI ABI)
virtual void emitDirectiveOptionArch(ArrayRef< RISCVOptionArchArg > Args)
virtual void finishAttributeSection()
virtual void emitDirectiveOptionPush()
Wrapper class representing virtual and physical registers.
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level stackmap operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
LLVM_ABI void recordStatepoint(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a statepoint instruction.
LLVM_ABI void recordPatchPoint(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a patchpoint instruction.
LLVM_ABI void recordStackMap(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a stackmap instruction.
MI-level Statepoint operands.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
ABI getTargetABI(StringRef ABIName)
static bool hasRoundModeOp(uint64_t TSFlags)
static bool isTiedPseudo(uint64_t TSFlags)
static bool hasVLOp(uint64_t TSFlags)
static bool hasVecPolicyOp(uint64_t TSFlags)
static bool hasSEWOp(uint64_t TSFlags)
void generateMCInstSeq(int64_t Val, const MCSubtargetInfo &STI, MCRegister DestReg, SmallVectorImpl< MCInst > &Insts)
bool compress(MCInst &OutInst, const MCInst &MI, const MCSubtargetInfo &STI)
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
static const MachineMemOperand::Flags MONontemporalBit1
Target & getTheRISCV32Target()
static const MachineMemOperand::Flags MONontemporalBit0
Target & getTheRISCV64beTarget()
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Target & getTheRISCV64Target()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
const SubtargetFeatureKV RISCVFeatureKV[RISCV::NumSubtargetFeatures]
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
@ MCSA_Hidden
.hidden (ELF)
Target & getTheRISCV32beTarget()
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Used to provide key value pairs for feature and CPU bit flags.