Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 944e60f

Browse filesBrowse files
committed
Sparc: Merge SparcMCInstLower.cpp into SparcAsmPrinter.cpp
Similar to https://reviews.llvm.org/D152311 for RISCV.
1 parent 4426355 commit 944e60f
Copy full SHA for 944e60f

File tree

Expand file treeCollapse file tree

5 files changed

+68
-109
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+68
-109
lines changed

‎llvm/lib/Target/Sparc/CMakeLists.txt

Copy file name to clipboardExpand all lines: llvm/lib/Target/Sparc/CMakeLists.txt
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ add_llvm_target(SparcCodeGen
2727
SparcRegisterInfo.cpp
2828
SparcSubtarget.cpp
2929
SparcTargetMachine.cpp
30-
SparcMCInstLower.cpp
3130
SparcTargetObjectFile.cpp
3231

3332
LINK_COMPONENTS

‎llvm/lib/Target/Sparc/Sparc.h

Copy file name to clipboardExpand all lines: llvm/lib/Target/Sparc/Sparc.h
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class SparcTargetMachine;
2929
FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
3030
FunctionPass *createSparcDelaySlotFillerPass();
3131

32-
void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
33-
AsmPrinter &AP);
3432
void initializeSparcDAGToDAGISelLegacyPass(PassRegistry &);
3533
void initializeErrataWorkaroundPass(PassRegistry &);
3634
} // namespace llvm

‎llvm/lib/Target/Sparc/SparcAsmPrinter.cpp

Copy file name to clipboardExpand all lines: llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+68-1Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class SparcAsmPrinter : public AsmPrinter {
6767

6868
void LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
6969
const MCSubtargetInfo &STI);
70+
71+
MCOperand lowerOperand(const MachineOperand &MO) const;
72+
73+
private:
74+
void lowerToMCInst(const MachineInstr *MI, MCInst &OutMI);
7075
};
7176
} // end of anonymous namespace
7277

@@ -255,6 +260,68 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
255260
EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
256261
}
257262

263+
MCOperand SparcAsmPrinter::lowerOperand(const MachineOperand &MO) const {
264+
switch (MO.getType()) {
265+
default:
266+
llvm_unreachable("unknown operand type");
267+
break;
268+
case MachineOperand::MO_Register:
269+
if (MO.isImplicit())
270+
break;
271+
return MCOperand::createReg(MO.getReg());
272+
273+
case MachineOperand::MO_Immediate:
274+
return MCOperand::createImm(MO.getImm());
275+
276+
case MachineOperand::MO_MachineBasicBlock:
277+
case MachineOperand::MO_GlobalAddress:
278+
case MachineOperand::MO_BlockAddress:
279+
case MachineOperand::MO_ExternalSymbol:
280+
case MachineOperand::MO_ConstantPoolIndex: {
281+
SparcMCExpr::Specifier Kind = (SparcMCExpr::Specifier)MO.getTargetFlags();
282+
const MCSymbol *Symbol = nullptr;
283+
switch (MO.getType()) {
284+
default:
285+
llvm_unreachable("");
286+
case MachineOperand::MO_MachineBasicBlock:
287+
Symbol = MO.getMBB()->getSymbol();
288+
break;
289+
case MachineOperand::MO_GlobalAddress:
290+
Symbol = getSymbol(MO.getGlobal());
291+
break;
292+
case MachineOperand::MO_BlockAddress:
293+
Symbol = GetBlockAddressSymbol(MO.getBlockAddress());
294+
break;
295+
case MachineOperand::MO_ExternalSymbol:
296+
Symbol = GetExternalSymbolSymbol(MO.getSymbolName());
297+
break;
298+
case MachineOperand::MO_ConstantPoolIndex:
299+
Symbol = GetCPISymbol(MO.getIndex());
300+
break;
301+
}
302+
303+
const MCExpr *expr = MCSymbolRefExpr::create(Symbol, OutContext);
304+
if (Kind)
305+
expr = SparcMCExpr::create(Kind, expr, OutContext);
306+
return MCOperand::createExpr(expr);
307+
}
308+
309+
case MachineOperand::MO_RegisterMask:
310+
break;
311+
}
312+
return MCOperand();
313+
}
314+
315+
void SparcAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) {
316+
OutMI.setOpcode(MI->getOpcode());
317+
318+
for (const MachineOperand &MO : MI->operands()) {
319+
MCOperand MCOp = lowerOperand(MO);
320+
if (MCOp.isValid())
321+
OutMI.addOperand(MCOp);
322+
}
323+
}
324+
258325
void SparcAsmPrinter::emitInstruction(const MachineInstr *MI) {
259326
Sparc_MC::verifyInstructionPredicates(MI->getOpcode(),
260327
getSubtargetInfo().getFeatureBits());
@@ -278,7 +345,7 @@ void SparcAsmPrinter::emitInstruction(const MachineInstr *MI) {
278345
MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
279346
do {
280347
MCInst TmpInst;
281-
LowerSparcMachineInstrToMCInst(&*I, TmpInst, *this);
348+
lowerToMCInst(&*I, TmpInst);
282349
EmitToStreamer(*OutStreamer, TmpInst);
283350
} while ((++I != E) && I->isInsideBundle()); // Delay slot check.
284351
}

‎llvm/lib/Target/Sparc/SparcMCInstLower.cpp

Copy file name to clipboardExpand all lines: llvm/lib/Target/Sparc/SparcMCInstLower.cpp
-104Lines changed: 0 additions & 104 deletions
This file was deleted.

‎llvm/utils/gn/secondary/llvm/lib/Target/Sparc/BUILD.gn

Copy file name to clipboardExpand all lines: llvm/utils/gn/secondary/llvm/lib/Target/Sparc/BUILD.gn
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ static_library("LLVMSparcCodeGen") {
3737
"SparcISelDAGToDAG.cpp",
3838
"SparcISelLowering.cpp",
3939
"SparcInstrInfo.cpp",
40-
"SparcMCInstLower.cpp",
4140
"SparcMachineFunctionInfo.cpp",
4241
"SparcRegisterInfo.cpp",
4342
"SparcSubtarget.cpp",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.