CACAO
X86_64Register.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/X86_64Register.cpp - X86_64Register
2 
3  Copyright (C) 2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
26 
27 namespace cacao {
28 namespace jit {
29 namespace compiler2 {
30 namespace x86_64 {
31 
33  X86_64Register* reg) : MachineRegister(reg->name, type),
34  reg(reg) {
35 }
36 
45 
46 const uint8_t GPRegister::base = 0;
47 const uint8_t SSERegister::base = 0;
48 
49 GPRegister RAX("RAX",0x0,false,0x0*8,8);
50 GPRegister RCX("RCX",0x1,false,0x1*8,8);
51 GPRegister RDX("RDX",0x2,false,0x2*8,8);
52 GPRegister RBX("RBX",0x3,false,0x3*8,8);
53 GPRegister RSP("RSP",0x4,false,0x4*8,8);
54 GPRegister RBP("RBP",0x5,false,0x5*8,8);
55 GPRegister RSI("RSI",0x6,false,0x6*8,8);
56 GPRegister RDI("RDI",0x7,false,0x7*8,8);
57 GPRegister R8 ("R8", 0x0,true ,0x8*8,8);
58 GPRegister R9 ("R9", 0x1,true ,0x9*8,8);
59 GPRegister R10("R10",0x2,true ,0xa*8,8);
60 GPRegister R11("R11",0x3,true ,0xb*8,8);
61 GPRegister R12("R12",0x4,true ,0xc*8,8);
62 GPRegister R13("R13",0x5,true ,0xd*8,8);
63 GPRegister R14("R14",0x6,true ,0xe*8,8);
64 GPRegister R15("R15",0x7,true ,0xf*8,8);
65 
67 &RDI, &RSI, &RDX, &RCX, &R8, &R9
68 };
70 &RAX,&R11,&R10,&R9,&R8,&RCX,&RDX,&RSI,&RDI};
72 
73 SSERegister XMM0 ("XMM0" ,0x0,false,0x0*16,16);
74 SSERegister XMM1 ("XMM1" ,0x1,false,0x1*16,16);
75 SSERegister XMM2 ("XMM2" ,0x2,false,0x2*16,16);
76 SSERegister XMM3 ("XMM3" ,0x3,false,0x3*16,16);
77 SSERegister XMM4 ("XMM4" ,0x4,false,0x4*16,16);
78 SSERegister XMM5 ("XMM5" ,0x5,false,0x5*16,16);
79 SSERegister XMM6 ("XMM6" ,0x6,false,0x6*16,16);
80 SSERegister XMM7 ("XMM7" ,0x7,false,0x7*16,16);
81 SSERegister XMM8 ("XMM8" ,0x0,true ,0x8*16,16);
82 SSERegister XMM9 ("XMM9" ,0x1,true ,0x9*16,16);
83 SSERegister XMM10("XMM10",0x2,true ,0xa*16,16);
84 SSERegister XMM11("XMM11",0x3,true ,0xb*16,16);
85 SSERegister XMM12("XMM12",0x4,true ,0xc*16,16);
86 SSERegister XMM13("XMM13",0x5,true ,0xd*16,16);
87 SSERegister XMM14("XMM14",0x6,true ,0xe*16,16);
88 SSERegister XMM15("XMM15",0x7,true ,0xf*16,16);
89 
91 &XMM0, &XMM1, &XMM2, &XMM3, &XMM4, &XMM5, &XMM6, &XMM7
92 };
93 
94 
95 
96 } // end namespace x86_64
97 using namespace x86_64;
98 
99 template<>
102  Type::TypeID type = MO->get_type();
103 
104  switch (type) {
105  case Type::CharTypeID:
106  case Type::ByteTypeID:
107  case Type::ShortTypeID:
108  case Type::IntTypeID:
109  case Type::LongTypeID:
111  #if 1
112  for(unsigned i = 0; i < IntegerCallerSavedRegistersSize ; ++i) {
113  OF.push_back(new x86_64::NativeRegister(type,IntegerCallerSavedRegisters[i]));
114  }
115  assert(OF.size() == IntegerCallerSavedRegistersSize);
116  #else
117  OF.push_back(new x86_64::NativeRegister(type,&RDI));
118  OF.push_back(new x86_64::NativeRegister(type,&RSI));
119  OF.push_back(new x86_64::NativeRegister(type,&RDX));
120  #endif
121  return OF;
122  case Type::FloatTypeID:
123  case Type::DoubleTypeID:
124  #if 1
125  for(unsigned i = 0; i < FloatArgumentRegisterSize ; ++i) {
126  OF.push_back(new x86_64::NativeRegister(type,FloatArgumentRegisters[i]));
127  }
128  assert(OF.size() == FloatArgumentRegisterSize);
129  #else
130  regs.push_back(&XMM0);
131  regs.push_back(&XMM1);
132  regs.push_back(&XMM2);
133  #endif
134  return OF;
135  default: break;
136  }
137  ABORT_MSG("X86_64 Register File Type Not supported!",
138  "Type: " << type);
139  return OF;
140 }
141 
142 } // end namespace compiler2
143 } // end namespace jit
144 } // end namespace cacao
145 
146 
147 /*
148  * These are local overrides for various environment variables in Emacs.
149  * Please do not remove this and leave it at the end of the file, where
150  * Emacs will automagically detect them.
151  * ---------------------------------------------------------------------
152  * Local variables:
153  * mode: c++
154  * indent-tabs-mode: t
155  * c-basic-offset: 4
156  * tab-width: 4
157  * End:
158  * vim:noexpandtab:sw=4:ts=4:
159  */
160 
GPRegister RDX("RDX", 0x2, false, 0x2 *8, 8)
GPRegister R9("R9", 0x1, true, 0x9 *8, 8)
char * regs[]
Definition: disass.c:51
This represents a machine register usage.
SSERegister XMM6("XMM6", 0x6, false, 0x6 *16, 16)
GPRegister R11("R11", 0x3, true, 0xb *8, 8)
SSERegister XMM9("XMM9", 0x1, true, 0x9 *16, 16)
SSERegister * FloatArgumentRegisters[]
SSERegister XMM1("XMM1", 0x1, false, 0x1 *16, 16)
SSERegister XMM4("XMM4", 0x4, false, 0x4 *16, 16)
SSERegister XMM12("XMM12", 0x4, true, 0xc *16, 16)
JNIEnv jclass jobject const char * name
Definition: jvmti.h:312
GPRegister R12("R12", 0x4, true, 0xc *8, 8)
GPRegister R14("R14", 0x6, true, 0xe *8, 8)
GPRegister RSI("RSI", 0x6, false, 0x6 *8, 8)
SSERegister XMM10("XMM10", 0x2, true, 0xa *16, 16)
SSERegister XMM2("XMM2", 0x2, false, 0x2 *16, 16)
GPRegister RBP("RBP", 0x5, false, 0x5 *8, 8)
GPRegister * IntegerCallerSavedRegisters[]
MIIterator i
alloc::list< MachineOperand * >::type OperandFile
const unsigned FloatArgumentRegisterSize
GPRegister * IntegerArgumentRegisters[]
GPRegister R15("R15", 0x7, true, 0xf *8, 8)
SSERegister XMM5("XMM5", 0x5, false, 0x5 *16, 16)
GPRegister R13("R13", 0x5, true, 0xd *8, 8)
SSERegister XMM13("XMM13", 0x5, true, 0xd *16, 16)
NativeRegister(Type::TypeID type, X86_64Register *reg)
GPRegister RDI("RDI", 0x7, false, 0x7 *8, 8)
GPRegister RCX("RCX", 0x1, false, 0x1 *8, 8)
Operands that can be directly used by the machine (register, memory, stackslot)
GPRegister R10("R10", 0x2, true, 0xa *8, 8)
SSERegister XMM7("XMM7", 0x7, false, 0x7 *16, 16)
GPRegister RAX("RAX", 0x0, false, 0x0 *8, 8)
SSERegister XMM8("XMM8", 0x0, true, 0x8 *16, 16)
SSERegister XMM3("XMM3", 0x3, false, 0x3 *16, 16)
SSERegister XMM0("XMM0", 0x0, false, 0x0 *16, 16)
SSERegister XMM14("XMM14", 0x6, true, 0xe *16, 16)
SSERegister XMM11("XMM11", 0x3, true, 0xb *16, 16)
#define ABORT_MSG(EXPR_SHORT, EXPR_LONG)
Definition: logging.hpp:133
GPRegister R8("R8", 0x0, true, 0x8 *8, 8)
GPRegister RBX("RBX", 0x3, false, 0x3 *8, 8)
GPRegister RSP("RSP", 0x4, false, 0x4 *8, 8)
virtual OperandFile & get_OperandFile(OperandFile &OF, MachineOperand *MO) const
SSERegister XMM15("XMM15", 0x7, true, 0xf *16, 16)