Go to the documentation of this file.
28 #define DEBUG_TYPE "asm-printer"
31 #include "SPIRVGenAsmWriter.inc"
37 bool SkipImmediates) {
38 const unsigned NumOps =
MI->getNumOperands();
39 for (
unsigned i = StartIndex;
i < NumOps; ++
i) {
40 if (!SkipImmediates || !
MI->getOperand(
i).isImm()) {
41 if (!SkipFirstSpace ||
i != StartIndex)
52 if (
MI->getNumOperands() - StartIndex == 2) {
54 Imm |= (
MI->getOperand(StartIndex + 1).getImm() << 32);
61 void SPIRVInstPrinter::recordOpExtInstImport(
const MCInst *
MI) {
68 const unsigned OpCode =
MI->getOpcode();
71 if (OpCode == SPIRV::OpDecorate) {
73 }
else if (OpCode == SPIRV::OpExtInstImport) {
74 recordOpExtInstImport(
MI);
75 }
else if (OpCode == SPIRV::OpExtInst) {
82 const unsigned LastFixedIndex = NumFixedOps - 1;
83 const int FirstVariableIndex = NumFixedOps;
84 if (NumFixedOps > 0 &&
90 case SPIRV::OpTypeImage:
94 case SPIRV::OpVariable:
98 case SPIRV::OpEntryPoint: {
104 case SPIRV::OpExecutionMode:
105 case SPIRV::OpExecutionModeId:
106 case SPIRV::OpLoopMerge: {
125 case SPIRV::OpImageSampleImplicitLod:
126 case SPIRV::OpImageSampleDrefImplicitLod:
127 case SPIRV::OpImageSampleProjImplicitLod:
128 case SPIRV::OpImageSampleProjDrefImplicitLod:
129 case SPIRV::OpImageFetch:
130 case SPIRV::OpImageGather:
131 case SPIRV::OpImageDrefGather:
132 case SPIRV::OpImageRead:
133 case SPIRV::OpImageWrite:
134 case SPIRV::OpImageSparseSampleImplicitLod:
135 case SPIRV::OpImageSparseSampleDrefImplicitLod:
136 case SPIRV::OpImageSparseSampleProjImplicitLod:
137 case SPIRV::OpImageSparseSampleProjDrefImplicitLod:
138 case SPIRV::OpImageSparseFetch:
139 case SPIRV::OpImageSparseGather:
140 case SPIRV::OpImageSparseDrefGather:
141 case SPIRV::OpImageSparseRead:
142 case SPIRV::OpImageSampleFootprintNV:
147 case SPIRV::OpCopyMemory:
148 case SPIRV::OpCopyMemorySized: {
149 const unsigned NumOps =
MI->getNumOperands();
150 for (
unsigned i = NumFixedOps;
i < NumOps; ++
i) {
153 if (
MI->getOperand(
i).getImm() &
155 assert(
i + 1 < NumOps &&
"Missing alignment operand");
163 case SPIRV::OpConstantI:
164 case SPIRV::OpConstantF:
188 if (NumFixedOps !=
MI->getNumOperands()) {
189 auto DecOp =
MI->getOperand(NumFixedOps - 1);
225 if (
const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr))
226 SRE = cast<MCSymbolRefExpr>(BE->getLHS());
228 SRE = cast<MCSymbolRefExpr>(Expr);
239 assert((Modifier == 0 || Modifier[0] == 0) &&
"No modifiers supported");
240 if (OpNo < MI->getNumOperands()) {
246 else if (
Op.isDFPImm())
248 else if (
Op.isExpr())
257 const unsigned NumOps =
MI->getNumOperands();
258 unsigned StrStartIndex = OpNo;
259 while (StrStartIndex < NumOps) {
260 if (
MI->getOperand(StrStartIndex).isReg())
264 if (StrStartIndex != OpNo)
274 unsigned numOpsInString = (Str.size() / 4) + 1;
275 StrStartIndex += numOpsInString;
278 if (
MI->getOpcode() == SPIRV::OpDecorate &&
279 MI->getOperand(1).getImm() ==
295 if (OpNo < MI->getNumOperands()) {
304 if (OpNo < MI->getNumOperands()) {
313 if (OpNo < MI->getNumOperands()) {
322 if (OpNo < MI->getNumOperands()) {
331 if (OpNo < MI->getNumOperands()) {
340 if (OpNo < MI->getNumOperands()) {
349 if (OpNo < MI->getNumOperands()) {
358 if (OpNo < MI->getNumOperands()) {
367 if (OpNo < MI->getNumOperands()) {
369 MI->getOperand(OpNo).getImm());
376 if (OpNo < MI->getNumOperands()) {
385 if (OpNo < MI->getNumOperands()) {
394 if (OpNo < MI->getNumOperands()) {
404 if (OpNo < MI->getNumOperands()) {
413 if (OpNo < MI->getNumOperands()) {
414 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
421 if (OpNo < MI->getNumOperands()) {
422 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
429 if (OpNo < MI->getNumOperands()) {
438 if (OpNo < MI->getNumOperands()) {
447 if (OpNo < MI->getNumOperands()) {
457 if (OpNo < MI->getNumOperands()) {
460 MI->getOperand(OpNo).getImm());
467 if (OpNo < MI->getNumOperands()) {
476 if (OpNo < MI->getNumOperands()) {
485 if (OpNo < MI->getNumOperands()) {
486 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
493 if (OpNo < MI->getNumOperands()) {
494 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
501 if (OpNo < MI->getNumOperands()) {
502 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
509 if (OpNo < MI->getNumOperands()) {
510 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
517 if (OpNo < MI->getNumOperands()) {
518 unsigned e =
static_cast<unsigned>(
MI->getOperand(OpNo).getImm());
525 if (OpNo < MI->getNumOperands()) {
533 if (OpNo < MI->getNumOperands()) {
542 if (OpNo < MI->getNumOperands()) {
551 if (OpNo < MI->getNumOperands()) {
VariantKind getKind() const
StringRef getSamplerAddressingModeName(SamplerAddressingMode e)
std::string getLoopControlName(uint32_t e)
This is an optimization pass for GlobalISel generic memory operations.
StringRef getSamplerFilterModeName(SamplerFilterMode e)
void printOpConstantVarOps(const MCInst *MI, unsigned StartIndex, raw_ostream &O)
StringRef getCapabilityName(Capability e)
void printImageOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printFPRoundingMode(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printMemoryModel(const MCInst *MI, unsigned OpNo, raw_ostream &O)
std::string getFPFastMathModeName(uint32_t e)
StringRef getSourceLanguageName(SourceLanguage e)
StringRef getImageChannelDataTypeName(ImageChannelDataType e)
StringRef getDecorationName(Decoration e)
FunctionParameterAttribute
void printMemorySemantics(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printKernelEnqueueFlags(const MCInst *MI, unsigned OpNo, raw_ostream &O)
StringRef getDimName(Dim dim)
StringRef getFunctionParameterAttributeName(FunctionParameterAttribute e)
StringRef getImageFormatName(ImageFormat e)
StringRef getMemoryModelName(MemoryModel e)
StringRef getKernelEnqueueFlagsName(KernelEnqueueFlags e)
Instances of this class represent a single low-level machine instruction.
Binary assembler expressions.
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS) override
Print the specified MCInst to the specified raw_ostream.
void printImageFormat(const MCInst *MI, unsigned OpNo, raw_ostream &O)
StringRef getAddressingModelName(AddressingModel e)
std::string getSelectionControlName(uint32_t e)
StringRef getLinkageTypeName(LinkageType e)
StringRef getAccessQualifierName(AccessQualifier e)
void printDecoration(const MCInst *MI, unsigned OpNo, raw_ostream &O)
StringRef getStorageClassName(StorageClass e)
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O, const char *Modifier=nullptr)
void printOpDecorate(const MCInst *MI, raw_ostream &O)
void printBuiltIn(const MCInst *MI, unsigned OpNo, raw_ostream &O)
StringRef getFPRoundingModeName(FPRoundingMode e)
Describe properties that are true of each instruction in the target description file.
void printSelectionControl(const MCInst *MI, unsigned OpNo, raw_ostream &O)
static void printExpr(const MCExpr *Expr, raw_ostream &O)
This class implements an extremely fast bulk output stream that can only output to a stream.
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
StringRef getExecutionModeName(ExecutionMode e)
void printExecutionModel(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printOpExtInst(const MCInst *MI, raw_ostream &O)
void printStorageClass(const MCInst *MI, unsigned OpNo, raw_ostream &O)
std::string getImageOperandName(uint32_t e)
StringRef getExecutionModelName(ExecutionModel e)
StringRef getGroupOperationName(GroupOperation e)
uint8_t OperandType
Information about the type of the operand.
StringRef getImageChannelOrderName(ImageChannelOrder e)
std::string getMemoryOperandName(uint32_t e)
StringRef getBuiltInName(BuiltIn e)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCOperandInfo * OpInfo
void printLinkageType(const MCInst *MI, unsigned OpNo, raw_ostream &O)
std::string getSPIRVStringOperand(const InstType &MI, unsigned StartIndex)
void printAddressingModel(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printImageChannelOrder(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Represent a reference to a symbol from inside an expression.
void printExecutionMode(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printFPFastMathMode(const MCInst *MI, unsigned OpNo, raw_ostream &O)
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void printFunctionControl(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printExtInst(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printAccessQualifier(const MCInst *MI, unsigned OpNo, raw_ostream &O)
StringRef getScopeName(Scope e)
void printLoopControl(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printImageChannelDataType(const MCInst *MI, unsigned OpNo, raw_ostream &O)
std::string getMemorySemanticsName(uint32_t e)
void printRemainingVariableOps(const MCInst *MI, unsigned StartIndex, raw_ostream &O, bool SkipFirstSpace=false, bool SkipImmediates=false)
StringRef getKernelProfilingInfoName(KernelProfilingInfo e)
void printFunctionParameterAttribute(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printScope(const MCInst *MI, unsigned OpNo, raw_ostream &O)
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
void printStringImm(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printKernelProfilingInfo(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printSourceLanguage(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printMemoryOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printDim(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printSamplerFilterMode(const MCInst *MI, unsigned OpNo, raw_ostream &O)
std::string getFunctionControlName(uint32_t e)
Instances of this class represent operands of the MCInst class.
void printSamplerAddressingMode(const MCInst *MI, unsigned OpNo, raw_ostream &O)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
static unsigned virtReg2Index(Register Reg)
Convert a virtual register number to a 0-based index.
Generic base class for all target subtargets.
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Base class for the full range of assembler expressions which are needed for parsing.
void printCapability(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printGroupOperation(const MCInst *MI, unsigned OpNo, raw_ostream &O)