Add support for the bswap instruction
authorChris Lattner <sabre@nondot.org>
Mon, 23 Dec 2002 23:46:00 +0000 (23:46 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 23 Dec 2002 23:46:00 +0000 (23:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5114 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/MachineCodeEmitter.cpp
lib/Target/X86/Printer.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86CodeEmitter.cpp

index dc9f4c08a739ec4ae2771b416e4092dd668d8268..79c1dbfe007dedee306abe28614c03c5904eaa8a 100644 (file)
@@ -238,7 +238,8 @@ void Emitter::emitInstruction(MachineInstr &MI) {
     break;
   case X86II::AddRegFrm:
     MCE.emitByte(BaseOpcode + getX86RegNum(MI.getOperand(0).getReg()));
-    if (MI.getNumOperands() == 2) {
+    if (MI.getNumOperands() == 2 && (MI.getOperand(1).isImmediate() ||
+       MI.getOperand(1).getVRegValueOrNull())) {
       unsigned Size = sizeOfPtr(Desc);
       if (Value *V = MI.getOperand(1).getVRegValueOrNull()) {
         assert(Size == 4 && "Don't know how to emit non-pointer values!");
index 84b43a06785374537a2acff183533a5183e70da3..385172dc0de36b6d3648e0dbb47f8e23dee4123f 100644 (file)
@@ -196,20 +196,22 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O,
     // or it takes a register and an immediate of the same size as the register
     // (move immediate f.e.).  Note that this immediate value might be stored as
     // an LLVM value, to represent, for example, loading the address of a global
-    // into a register.
+    // into a register.  The initial register might be duplicated if this is a
+    // M_2_ADDR_REG instruction
     //
     assert(MI->getOperand(0).isRegister() &&
            (MI->getNumOperands() == 1 || 
             (MI->getNumOperands() == 2 &&
              (MI->getOperand(1).getVRegValueOrNull() ||
-              MI->getOperand(1).isImmediate()))) &&
+              MI->getOperand(1).isImmediate() ||
+             MI->getOperand(1).isRegister()))) &&
            "Illegal form for AddRegFrm instruction!");
 
     unsigned Reg = MI->getOperand(0).getReg();
     
     O << getName(MI->getOpCode()) << " ";
     printOp(O, MI->getOperand(0), RI);
-    if (MI->getNumOperands() == 2) {
+    if (MI->getNumOperands() == 2 && !MI->getOperand(1).isRegister()) {
       O << ", ";
       printOp(O, MI->getOperand(1), RI);
     }
index 84b43a06785374537a2acff183533a5183e70da3..385172dc0de36b6d3648e0dbb47f8e23dee4123f 100644 (file)
@@ -196,20 +196,22 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O,
     // or it takes a register and an immediate of the same size as the register
     // (move immediate f.e.).  Note that this immediate value might be stored as
     // an LLVM value, to represent, for example, loading the address of a global
-    // into a register.
+    // into a register.  The initial register might be duplicated if this is a
+    // M_2_ADDR_REG instruction
     //
     assert(MI->getOperand(0).isRegister() &&
            (MI->getNumOperands() == 1 || 
             (MI->getNumOperands() == 2 &&
              (MI->getOperand(1).getVRegValueOrNull() ||
-              MI->getOperand(1).isImmediate()))) &&
+              MI->getOperand(1).isImmediate() ||
+             MI->getOperand(1).isRegister()))) &&
            "Illegal form for AddRegFrm instruction!");
 
     unsigned Reg = MI->getOperand(0).getReg();
     
     O << getName(MI->getOpCode()) << " ";
     printOp(O, MI->getOperand(0), RI);
-    if (MI->getNumOperands() == 2) {
+    if (MI->getNumOperands() == 2 && !MI->getOperand(1).isRegister()) {
       O << ", ";
       printOp(O, MI->getOperand(1), RI);
     }
index dc9f4c08a739ec4ae2771b416e4092dd668d8268..79c1dbfe007dedee306abe28614c03c5904eaa8a 100644 (file)
@@ -238,7 +238,8 @@ void Emitter::emitInstruction(MachineInstr &MI) {
     break;
   case X86II::AddRegFrm:
     MCE.emitByte(BaseOpcode + getX86RegNum(MI.getOperand(0).getReg()));
-    if (MI.getNumOperands() == 2) {
+    if (MI.getNumOperands() == 2 && (MI.getOperand(1).isImmediate() ||
+       MI.getOperand(1).getVRegValueOrNull())) {
       unsigned Size = sizeOfPtr(Desc);
       if (Value *V = MI.getOperand(1).getVRegValueOrNull()) {
         assert(Size == 4 && "Don't know how to emit non-pointer values!");