llvm.org GIT mirror llvm / f4d25a2
Change getX86SubSuperRegister to take an MVT::SimpleValueType rather than an EVT and add llvm_unreachable to the switches. Helps it compile to dramatically better code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164919 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 8 years ago
4 changed file(s) with 12 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
242242 if (AsmVariant == 0) O << '%';
243243 unsigned Reg = MO.getReg();
244244 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
245 EVT VT = (strcmp(Modifier+6,"64") == 0) ?
245 MVT::SimpleValueType VT = (strcmp(Modifier+6,"64") == 0) ?
246246 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
247247 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
248248 Reg = getX86SubSuperRegister(Reg, VT);
1210912109 SrcReg = MI->getOperand(CurOp++).getReg();
1211012110
1211112111 const TargetRegisterClass *RC = MRI.getRegClass(DstReg);
12112 EVT VT = *RC->vt_begin();
12112 MVT::SimpleValueType VT = *RC->vt_begin();
1211312113 unsigned AccPhyReg = getX86SubSuperRegister(X86::EAX, VT);
1211412114
1211512115 unsigned LCMPXCHGOpc = getCmpXChgOpcode(VT);
589589 }
590590
591591 namespace llvm {
592 unsigned getX86SubSuperRegister(unsigned Reg, EVT VT, bool High) {
593 switch (VT.getSimpleVT().SimpleTy) {
594 default: return Reg;
592 unsigned getX86SubSuperRegister(unsigned Reg, MVT::SimpleValueType VT,
593 bool High) {
594 switch (VT) {
595 default: llvm_unreachable("Unexpected VT");
595596 case MVT::i8:
596597 if (High) {
597598 switch (Reg) {
607608 }
608609 } else {
609610 switch (Reg) {
610 default: return 0;
611 default: llvm_unreachable("Unexpected register");
611612 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
612613 return X86::AL;
613614 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
644645 }
645646 case MVT::i16:
646647 switch (Reg) {
647 default: return Reg;
648 default: llvm_unreachable("Unexpected register");
648649 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
649650 return X86::AX;
650651 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
680681 }
681682 case MVT::i32:
682683 switch (Reg) {
683 default: return Reg;
684 default: llvm_unreachable("Unexpected register");
684685 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
685686 return X86::EAX;
686687 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
732733 }
733734 }
734735 switch (Reg) {
735 default: return Reg;
736 default: llvm_unreachable("Unexpected register");
736737 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
737738 return X86::RAX;
738739 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
140140
141141 // getX86SubSuperRegister - X86 utility function. It returns the sub or super
142142 // register of a specific X86 register.
143 // e.g. getX86SubSuperRegister(X86::EAX, EVT::i16) return X86:AX
144 unsigned getX86SubSuperRegister(unsigned, EVT, bool High=false);
143 // e.g. getX86SubSuperRegister(X86::EAX, MVT::i16) return X86:AX
144 unsigned getX86SubSuperRegister(unsigned, MVT::SimpleValueType, bool High=false);
145145
146146 } // End llvm namespace
147147