1 //===-- PPCBaseInfo.h - Top level definitions for PPC -------- --*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file contains small standalone helper functions and enum definitions for 11 // the PPC target useful for the compiler back-end and the MC libraries. 12 // As such, it deliberately does not include references to LLVM core 13 // code gen types, passes, etc.. 14 // 15 //===----------------------------------------------------------------------===// 16 17 #ifndef PPCBASEINFO_H 18 #define PPCBASEINFO_H 19 20 #include "PPCMCTargetDesc.h" 21 #include "llvm/Support/ErrorHandling.h" 22 23 namespace llvm { 24 25 /// getPPCRegisterNumbering - Given the enum value for some register, e.g. 26 /// PPC::F14, return the number that it corresponds to (e.g. 14). getPPCRegisterNumbering(unsigned RegEnum)27inline static unsigned getPPCRegisterNumbering(unsigned RegEnum) { 28 using namespace PPC; 29 switch (RegEnum) { 30 case 0: return 0; 31 case R0 : case X0 : case F0 : case V0 : case CR0: case CR0LT: return 0; 32 case R1 : case X1 : case F1 : case V1 : case CR1: case CR0GT: return 1; 33 case R2 : case X2 : case F2 : case V2 : case CR2: case CR0EQ: return 2; 34 case R3 : case X3 : case F3 : case V3 : case CR3: case CR0UN: return 3; 35 case R4 : case X4 : case F4 : case V4 : case CR4: case CR1LT: return 4; 36 case R5 : case X5 : case F5 : case V5 : case CR5: case CR1GT: return 5; 37 case R6 : case X6 : case F6 : case V6 : case CR6: case CR1EQ: return 6; 38 case R7 : case X7 : case F7 : case V7 : case CR7: case CR1UN: return 7; 39 case R8 : case X8 : case F8 : case V8 : case CR2LT: return 8; 40 case R9 : case X9 : case F9 : case V9 : case CR2GT: return 9; 41 case R10: case X10: case F10: case V10: case CR2EQ: return 10; 42 case R11: case X11: case F11: case V11: case CR2UN: return 11; 43 case R12: case X12: case F12: case V12: case CR3LT: return 12; 44 case R13: case X13: case F13: case V13: case CR3GT: return 13; 45 case R14: case X14: case F14: case V14: case CR3EQ: return 14; 46 case R15: case X15: case F15: case V15: case CR3UN: return 15; 47 case R16: case X16: case F16: case V16: case CR4LT: return 16; 48 case R17: case X17: case F17: case V17: case CR4GT: return 17; 49 case R18: case X18: case F18: case V18: case CR4EQ: return 18; 50 case R19: case X19: case F19: case V19: case CR4UN: return 19; 51 case R20: case X20: case F20: case V20: case CR5LT: return 20; 52 case R21: case X21: case F21: case V21: case CR5GT: return 21; 53 case R22: case X22: case F22: case V22: case CR5EQ: return 22; 54 case R23: case X23: case F23: case V23: case CR5UN: return 23; 55 case R24: case X24: case F24: case V24: case CR6LT: return 24; 56 case R25: case X25: case F25: case V25: case CR6GT: return 25; 57 case R26: case X26: case F26: case V26: case CR6EQ: return 26; 58 case R27: case X27: case F27: case V27: case CR6UN: return 27; 59 case R28: case X28: case F28: case V28: case CR7LT: return 28; 60 case R29: case X29: case F29: case V29: case CR7GT: return 29; 61 case R30: case X30: case F30: case V30: case CR7EQ: return 30; 62 case R31: case X31: case F31: case V31: case CR7UN: return 31; 63 default: 64 llvm_unreachable("Unhandled reg in PPCRegisterInfo::getRegisterNumbering!"); 65 } 66 } 67 68 } // end namespace llvm; 69 70 #endif 71