add basic encoding support for immediates and registers, allowing us
authorChris Lattner <sabre@nondot.org>
Mon, 15 Nov 2010 04:51:55 +0000 (04:51 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Nov 2010 04:51:55 +0000 (04:51 +0000)
to encode all of these instructions correctly (for example):

        mflr r0                         ; encoding: [0x7c,0x08,0x02,0xa6]
        stw r0, 8(r1)                   ; encoding: [0x90,0x01,0x00,0x08]
        stwu r1, -64(r1)                ; encoding: [0x94,0x21,0xff,0xc0]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119118 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCInstrInfo.td
lib/Target/PowerPC/PPCMCCodeEmitter.cpp

index 8d9fa471322e35983e32f201430b397af5550484..05fdbeb8633c9d0051fd467f805107738003d5e7 100644 (file)
@@ -295,9 +295,7 @@ def calltarget : Operand<iPTR> {
 def aaddr : Operand<iPTR> {
   let PrintMethod = "printAbsAddrOperand";
 }
-def piclabel: Operand<iPTR> {
-  let PrintMethod = "printPICLabel";
-}
+def piclabel: Operand<iPTR> {}
 def symbolHi: Operand<i32> {
   let PrintMethod = "printSymbolHi";
 }
@@ -321,7 +319,6 @@ def memrix : Operand<iPTR> {   // memri where the imm is shifted 2 bits.
   let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg);
 }
 def tocentry : Operand<iPTR> {
-  let PrintMethod = "printTOCEntryLabel";
   let MIOperandInfo = (ops i32imm:$imm);
 }
 
index 889fe0f046d3c9b59350e7b742abbeb84fba307a..fd98f4dfb131f5c786bad23777d0174251afc69f 100644 (file)
@@ -13,6 +13,7 @@
 
 #define DEBUG_TYPE "mccodeemitter"
 #include "PPC.h"
+#include "PPCRegisterInfo.h"
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/ADT/Statistic.h"
@@ -91,6 +92,12 @@ MCCodeEmitter *llvm::createPPCMCCodeEmitter(const Target &, TargetMachine &TM,
 unsigned PPCMCCodeEmitter::
 getMachineOpValue(const MCInst &MI, const MCOperand &MO,
                   SmallVectorImpl<MCFixup> &Fixups) const {
+  if (MO.isReg())
+    return PPCRegisterInfo::getRegisterNumbering(MO.getReg());
+  
+  if (MO.isImm())
+    return MO.getImm();
+  
   // FIXME.
   return 0;
 }