aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/LowerSubregs.cpp
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2008-03-10 06:12:08 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2008-03-10 06:12:08 +0000
commit5615ce4ec4c1b68fd48f4a19bc19a4f77c97c20a (patch)
treeca6ec84f80cafe500a012b1aab9a96e34a305084 /lib/CodeGen/LowerSubregs.cpp
parent92b80c71b23a7b666e2e3f2a16545c05c4dd7190 (diff)
downloadexternal_llvm-5615ce4ec4c1b68fd48f4a19bc19a4f77c97c20a.zip
external_llvm-5615ce4ec4c1b68fd48f4a19bc19a4f77c97c20a.tar.gz
external_llvm-5615ce4ec4c1b68fd48f4a19bc19a4f77c97c20a.tar.bz2
Allow insert_subreg into implicit, target-specific values.
Change insert/extract subreg instructions to be able to be used in TableGen patterns. Use the above features to reimplement an x86-64 pseudo instruction as a pattern. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LowerSubregs.cpp')
-rw-r--r--lib/CodeGen/LowerSubregs.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/lib/CodeGen/LowerSubregs.cpp b/lib/CodeGen/LowerSubregs.cpp
index 232dc06..e7812d4 100644
--- a/lib/CodeGen/LowerSubregs.cpp
+++ b/lib/CodeGen/LowerSubregs.cpp
@@ -105,32 +105,21 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) {
MachineFunction &MF = *MBB->getParent();
const TargetRegisterInfo &TRI = *MF.getTarget().getRegisterInfo();
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
- unsigned DstReg = 0;
+ assert((MI->getOperand(0).isRegister() && MI->getOperand(0).isDef()) &&
+ ((MI->getOperand(1).isRegister() && MI->getOperand(1).isUse()) ||
+ MI->getOperand(1).isImmediate()) &&
+ (MI->getOperand(2).isRegister() && MI->getOperand(2).isUse()) &&
+ MI->getOperand(3).isImmediate() && "Invalid insert_subreg");
+
+ unsigned DstReg = MI->getOperand(0).getReg();
unsigned SrcReg = 0;
- unsigned InsReg = 0;
- unsigned SubIdx = 0;
-
- // If only have 3 operands, then the source superreg is undef
- // and we can supress the copy from the undef value
- if (MI->getNumOperands() == 3) {
- assert((MI->getOperand(0).isRegister() && MI->getOperand(0).isDef()) &&
- (MI->getOperand(1).isRegister() && MI->getOperand(1).isUse()) &&
- MI->getOperand(2).isImmediate() && "Invalid extract_subreg");
- DstReg = MI->getOperand(0).getReg();
+ // Check if we're inserting into an implicit value.
+ if (MI->getOperand(1).isImmediate())
SrcReg = DstReg;
- InsReg = MI->getOperand(1).getReg();
- SubIdx = MI->getOperand(2).getImm();
- } else if (MI->getNumOperands() == 4) {
- assert((MI->getOperand(0).isRegister() && MI->getOperand(0).isDef()) &&
- (MI->getOperand(1).isRegister() && MI->getOperand(1).isUse()) &&
- (MI->getOperand(2).isRegister() && MI->getOperand(2).isUse()) &&
- MI->getOperand(3).isImmediate() && "Invalid extract_subreg");
- DstReg = MI->getOperand(0).getReg();
+ else
SrcReg = MI->getOperand(1).getReg();
- InsReg = MI->getOperand(2).getReg();
- SubIdx = MI->getOperand(3).getImm();
- } else
- assert(0 && "Malformed extract_subreg");
+ unsigned InsReg = MI->getOperand(2).getReg();
+ unsigned SubIdx = MI->getOperand(3).getImm();
assert(SubIdx != 0 && "Invalid index for extract_subreg");
unsigned DstSubReg = TRI.getSubReg(DstReg, SubIdx);