Skip to content

Commit 7f6f186

Browse files
authored
[SPIRV] Stop including SPIRVInstrInfo.h in MCTargetDesc. NFC (#128443)
SPIRVInstrInfo.h is a CodeGen layer file, it should not be used in MC layer files. This required adding a new enum for MCInst flags and a conversion from MachineInstr's AsmPrinter flags in SPIRVMCInstLower.
1 parent a6abbe0 commit 7f6f186

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ struct ExtendedBuiltin {
222222
InstructionSet::InstructionSet Set;
223223
uint32_t Number;
224224
};
225+
226+
enum InstFlags {
227+
// It is a half type
228+
INST_PRINTER_WIDTH16 = 1
229+
};
225230
} // namespace SPIRV
226231

227232
using CapabilityList = SmallVector<SPIRV::Capability::Capability, 8>;

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "SPIRVInstPrinter.h"
1414
#include "SPIRV.h"
1515
#include "SPIRVBaseInfo.h"
16-
#include "SPIRVInstrInfo.h"
1716
#include "llvm/ADT/APFloat.h"
1817
#include "llvm/CodeGen/Register.h"
1918
#include "llvm/MC/MCAsmInfo.h"
@@ -51,7 +50,7 @@ void SPIRVInstPrinter::printRemainingVariableOps(const MCInst *MI,
5150
void SPIRVInstPrinter::printOpConstantVarOps(const MCInst *MI,
5251
unsigned StartIndex,
5352
raw_ostream &O) {
54-
unsigned IsBitwidth16 = MI->getFlags() & SPIRV::ASM_PRINTER_WIDTH16;
53+
unsigned IsBitwidth16 = MI->getFlags() & SPIRV::INST_PRINTER_WIDTH16;
5554
const unsigned NumVarOps = MI->getNumOperands() - StartIndex;
5655

5756
assert((NumVarOps == 1 || NumVarOps == 2) &&

llvm/lib/Target/SPIRV/SPIRVMCInstLower.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ void SPIRVMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI,
2424
SPIRV::ModuleAnalysisInfo *MAI) const {
2525
OutMI.setOpcode(MI->getOpcode());
2626
// Propagate previously set flags
27-
OutMI.setFlags(MI->getAsmPrinterFlags());
27+
if (MI->getAsmPrinterFlags() & SPIRV::ASM_PRINTER_WIDTH16)
28+
OutMI.setFlags(SPIRV::INST_PRINTER_WIDTH16);
2829
const MachineFunction *MF = MI->getMF();
2930
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
3031
const MachineOperand &MO = MI->getOperand(i);

0 commit comments

Comments
 (0)