[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Feb 23 11:31:22 PST 2006
Changes in directory llvm/lib/Target/PowerPC:
PPCAsmPrinter.cpp updated: 1.154 -> 1.155
---
Log message:
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
---
Diffs of the changes: (+28 -4)
PPCAsmPrinter.cpp | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.154 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.155
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.154 Wed Feb 22 14:19:42 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Thu Feb 23 13:31:10 2006
@@ -97,10 +97,7 @@
}
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 @@
}
}
+/// 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.
///
More information about the llvm-commits
mailing list