diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-23 19:31:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-23 19:31:10 +0000 |
commit | e3f01570c172570fb2c0bacc6b8860ee6809362d (patch) | |
tree | a62d4cc760f8855ed402c515031d8930ffa8e0ab | |
parent | c3a9f8d31ce93ba384bd2bbdd55c757b06600a15 (diff) |
Implement the PPC inline asm "L" modifier. This allows us to compile:
long long test(long long X) {
__asm__("foo %0 %L0 %1 %L1" : "=r"(X): "r"(X));
return X;
}
to:
foo r2 r3 r2 r3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26333 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PowerPC/PPCAsmPrinter.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 714a36d1e7..76ca256832 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -97,10 +97,7 @@ namespace { } bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, - unsigned AsmVariant, const char *ExtraCode) { - printOperand(MI, OpNo); - return false; - } + unsigned AsmVariant, const char *ExtraCode); void printU5ImmOperand(const MachineInstr *MI, unsigned OpNo) { unsigned char value = MI->getOperand(OpNo).getImmedValue(); @@ -396,6 +393,33 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) { } } +/// PrintAsmOperand - Print out an operand for an inline asm expression. +/// +bool PPCAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, + unsigned AsmVariant, + const char *ExtraCode) { + // Does this asm operand have a single letter operand modifier? + if (ExtraCode && ExtraCode[0]) { + if (ExtraCode[1] != 0) return true; // Unknown modifier. + + switch (ExtraCode[0]) { + default: return true; // Unknown modifier. + case 'L': // Write second word of DImode reference. + // Verify that this operand has two consecutive registers. + if (!MI->getOperand(OpNo).isRegister() || + OpNo+1 == MI->getNumOperands() || + !MI->getOperand(OpNo+1).isRegister()) + return true; + ++OpNo; // Return the high-part. + break; + } + } + + printOperand(MI, OpNo); + return false; +} + + /// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax to /// the current output stream. /// |