llvm.org GIT mirror llvm / 894bfb2
[X86] Move getX86SubSuperRegisterOrZero to X86MCTargetDesc.cpp so it can be used by AsmParser library without depending on X86CodeGen library. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256428 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 4 years ago
5 changed file(s) with 193 addition(s) and 193 deletion(s). Raw diff Collapse all Expand all
99 #include "MCTargetDesc/X86BaseInfo.h"
1010 #include "X86AsmInstrumentation.h"
1111 #include "X86Operand.h"
12 #include "X86RegisterInfo.h"
1312 #include "llvm/ADT/StringExtras.h"
1413 #include "llvm/ADT/Triple.h"
1514 #include "llvm/MC/MCAsmInfo.h"
267267 TargetRegistry::RegisterMCAsmBackend(TheX86_64Target,
268268 createX86_64AsmBackend);
269269 }
270
271 unsigned llvm::getX86SubSuperRegisterOrZero(unsigned Reg, unsigned Size,
272 bool High) {
273 switch (Size) {
274 default: return 0;
275 case 8:
276 if (High) {
277 switch (Reg) {
278 default: return getX86SubSuperRegisterOrZero(Reg, 64);
279 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
280 return X86::SI;
281 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
282 return X86::DI;
283 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
284 return X86::BP;
285 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
286 return X86::SP;
287 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
288 return X86::AH;
289 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
290 return X86::DH;
291 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
292 return X86::CH;
293 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
294 return X86::BH;
295 }
296 } else {
297 switch (Reg) {
298 default: return 0;
299 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
300 return X86::AL;
301 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
302 return X86::DL;
303 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
304 return X86::CL;
305 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
306 return X86::BL;
307 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
308 return X86::SIL;
309 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
310 return X86::DIL;
311 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
312 return X86::BPL;
313 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
314 return X86::SPL;
315 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
316 return X86::R8B;
317 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
318 return X86::R9B;
319 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
320 return X86::R10B;
321 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
322 return X86::R11B;
323 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
324 return X86::R12B;
325 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
326 return X86::R13B;
327 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
328 return X86::R14B;
329 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
330 return X86::R15B;
331 }
332 }
333 case 16:
334 switch (Reg) {
335 default: return 0;
336 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
337 return X86::AX;
338 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
339 return X86::DX;
340 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
341 return X86::CX;
342 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
343 return X86::BX;
344 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
345 return X86::SI;
346 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
347 return X86::DI;
348 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
349 return X86::BP;
350 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
351 return X86::SP;
352 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
353 return X86::R8W;
354 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
355 return X86::R9W;
356 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
357 return X86::R10W;
358 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
359 return X86::R11W;
360 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
361 return X86::R12W;
362 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
363 return X86::R13W;
364 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
365 return X86::R14W;
366 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
367 return X86::R15W;
368 }
369 case 32:
370 switch (Reg) {
371 default: return 0;
372 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
373 return X86::EAX;
374 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
375 return X86::EDX;
376 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
377 return X86::ECX;
378 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
379 return X86::EBX;
380 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
381 return X86::ESI;
382 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
383 return X86::EDI;
384 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
385 return X86::EBP;
386 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
387 return X86::ESP;
388 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
389 return X86::R8D;
390 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
391 return X86::R9D;
392 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
393 return X86::R10D;
394 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
395 return X86::R11D;
396 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
397 return X86::R12D;
398 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
399 return X86::R13D;
400 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
401 return X86::R14D;
402 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
403 return X86::R15D;
404 }
405 case 64:
406 switch (Reg) {
407 default: return 0;
408 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
409 return X86::RAX;
410 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
411 return X86::RDX;
412 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
413 return X86::RCX;
414 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
415 return X86::RBX;
416 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
417 return X86::RSI;
418 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
419 return X86::RDI;
420 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
421 return X86::RBP;
422 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
423 return X86::RSP;
424 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
425 return X86::R8;
426 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
427 return X86::R9;
428 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
429 return X86::R10;
430 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
431 return X86::R11;
432 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
433 return X86::R12;
434 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
435 return X86::R13;
436 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
437 return X86::R14;
438 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
439 return X86::R15;
440 }
441 }
442 }
443
444 unsigned llvm::getX86SubSuperRegister(unsigned Reg, unsigned Size, bool High) {
445 unsigned Res = getX86SubSuperRegisterOrZero(Reg, Size, High);
446 assert(Res != 0 && "Unexpected register or VT");
447 return Res;
448 }
449
450
9797
9898 /// Construct X86-64 ELF relocation info.
9999 MCRelocationInfo *createX86_64ELFRelocationInfo(MCContext &Ctx);
100
101 /// Returns the sub or super register of a specific X86 register.
102 /// e.g. getX86SubSuperRegister(X86::EAX, 16) returns X86::AX.
103 /// Aborts on error.
104 unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false);
105
106 /// Returns the sub or super register of a specific X86 register.
107 /// Like getX86SubSuperRegister() but returns 0 on error.
108 unsigned getX86SubSuperRegisterOrZero(unsigned, unsigned,
109 bool High = false);
110
100111 } // End llvm namespace
101112
102113
627627 return FrameReg;
628628 }
629629
630 namespace llvm {
631 unsigned getX86SubSuperRegisterOrZero(unsigned Reg, unsigned Size, bool High) {
632 switch (Size) {
633 default: return 0;
634 case 8:
635 if (High) {
636 switch (Reg) {
637 default: return getX86SubSuperRegisterOrZero(Reg, 64);
638 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
639 return X86::SI;
640 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
641 return X86::DI;
642 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
643 return X86::BP;
644 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
645 return X86::SP;
646 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
647 return X86::AH;
648 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
649 return X86::DH;
650 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
651 return X86::CH;
652 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
653 return X86::BH;
654 }
655 } else {
656 switch (Reg) {
657 default: return 0;
658 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
659 return X86::AL;
660 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
661 return X86::DL;
662 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
663 return X86::CL;
664 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
665 return X86::BL;
666 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
667 return X86::SIL;
668 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
669 return X86::DIL;
670 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
671 return X86::BPL;
672 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
673 return X86::SPL;
674 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
675 return X86::R8B;
676 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
677 return X86::R9B;
678 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
679 return X86::R10B;
680 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
681 return X86::R11B;
682 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
683 return X86::R12B;
684 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
685 return X86::R13B;
686 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
687 return X86::R14B;
688 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
689 return X86::R15B;
690 }
691 }
692 case 16:
693 switch (Reg) {
694 default: return 0;
695 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
696 return X86::AX;
697 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
698 return X86::DX;
699 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
700 return X86::CX;
701 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
702 return X86::BX;
703 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
704 return X86::SI;
705 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
706 return X86::DI;
707 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
708 return X86::BP;
709 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
710 return X86::SP;
711 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
712 return X86::R8W;
713 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
714 return X86::R9W;
715 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
716 return X86::R10W;
717 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
718 return X86::R11W;
719 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
720 return X86::R12W;
721 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
722 return X86::R13W;
723 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
724 return X86::R14W;
725 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
726 return X86::R15W;
727 }
728 case 32:
729 switch (Reg) {
730 default: return 0;
731 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
732 return X86::EAX;
733 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
734 return X86::EDX;
735 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
736 return X86::ECX;
737 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
738 return X86::EBX;
739 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
740 return X86::ESI;
741 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
742 return X86::EDI;
743 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
744 return X86::EBP;
745 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
746 return X86::ESP;
747 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
748 return X86::R8D;
749 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
750 return X86::R9D;
751 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
752 return X86::R10D;
753 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
754 return X86::R11D;
755 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
756 return X86::R12D;
757 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
758 return X86::R13D;
759 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
760 return X86::R14D;
761 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
762 return X86::R15D;
763 }
764 case 64:
765 switch (Reg) {
766 default: return 0;
767 case X86::AH: case X86::AL: case X86::AX: case X86::EAX: case X86::RAX:
768 return X86::RAX;
769 case X86::DH: case X86::DL: case X86::DX: case X86::EDX: case X86::RDX:
770 return X86::RDX;
771 case X86::CH: case X86::CL: case X86::CX: case X86::ECX: case X86::RCX:
772 return X86::RCX;
773 case X86::BH: case X86::BL: case X86::BX: case X86::EBX: case X86::RBX:
774 return X86::RBX;
775 case X86::SIL: case X86::SI: case X86::ESI: case X86::RSI:
776 return X86::RSI;
777 case X86::DIL: case X86::DI: case X86::EDI: case X86::RDI:
778 return X86::RDI;
779 case X86::BPL: case X86::BP: case X86::EBP: case X86::RBP:
780 return X86::RBP;
781 case X86::SPL: case X86::SP: case X86::ESP: case X86::RSP:
782 return X86::RSP;
783 case X86::R8B: case X86::R8W: case X86::R8D: case X86::R8:
784 return X86::R8;
785 case X86::R9B: case X86::R9W: case X86::R9D: case X86::R9:
786 return X86::R9;
787 case X86::R10B: case X86::R10W: case X86::R10D: case X86::R10:
788 return X86::R10;
789 case X86::R11B: case X86::R11W: case X86::R11D: case X86::R11:
790 return X86::R11;
791 case X86::R12B: case X86::R12W: case X86::R12D: case X86::R12:
792 return X86::R12;
793 case X86::R13B: case X86::R13W: case X86::R13D: case X86::R13:
794 return X86::R13;
795 case X86::R14B: case X86::R14W: case X86::R14D: case X86::R14:
796 return X86::R14;
797 case X86::R15B: case X86::R15W: case X86::R15D: case X86::R15:
798 return X86::R15;
799 }
800 }
801 }
802
803 unsigned getX86SubSuperRegister(unsigned Reg, unsigned Size, bool High) {
804 unsigned Res = getX86SubSuperRegisterOrZero(Reg, Size, High);
805 assert(Res != 0 && "Unexpected register or VT");
806 return Res;
807 }
808
809 unsigned get512BitSuperRegister(unsigned Reg) {
630 unsigned llvm::get512BitSuperRegister(unsigned Reg) {
810631 if (Reg >= X86::XMM0 && Reg <= X86::XMM31)
811632 return X86::ZMM0 + (Reg - X86::XMM0);
812633 if (Reg >= X86::YMM0 && Reg <= X86::YMM31)
815636 return Reg;
816637 llvm_unreachable("Unexpected SIMD register");
817638 }
818
819 }
134134 unsigned getSlotSize() const { return SlotSize; }
135135 };
136136
137 /// Returns the sub or super register of a specific X86 register.
138 /// e.g. getX86SubSuperRegister(X86::EAX, 16) returns X86::AX.
139 /// Aborts on error.
140 unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false);
141
142 /// Returns the sub or super register of a specific X86 register.
143 /// Like getX86SubSuperRegister() but returns 0 on error.
144 unsigned getX86SubSuperRegisterOrZero(unsigned, unsigned,
145 bool High = false);
146
147137 //get512BitRegister - X86 utility - returns 512-bit super register
148138 unsigned get512BitSuperRegister(unsigned Reg);
149139