blob: d08ffa4a89a989c9e0196bc61cd7955fa342afea [file] [log] [blame]
Chris Lattner556d89d2003-08-01 22:19:03 +00001//===-- SparcV9CodeEmitter.cpp --------------------------------------------===//
Misha Brukmana9f7f6e2003-05-30 20:17:33 +00002//
Chris Lattner556d89d2003-08-01 22:19:03 +00003// FIXME: document
Misha Brukmana9f7f6e2003-05-30 20:17:33 +00004//
5//===----------------------------------------------------------------------===//
6
Misha Brukmanf86aaa82003-06-02 04:12:39 +00007#include "llvm/Constants.h"
8#include "llvm/Function.h"
9#include "llvm/GlobalVariable.h"
Misha Brukman3de36f52003-05-27 20:07:58 +000010#include "llvm/PassManager.h"
11#include "llvm/CodeGen/MachineCodeEmitter.h"
Misha Brukmana2196c12003-06-04 20:01:13 +000012#include "llvm/CodeGen/MachineConstantPool.h"
Misha Brukmanf86aaa82003-06-02 04:12:39 +000013#include "llvm/CodeGen/MachineFunctionInfo.h"
Misha Brukman3de36f52003-05-27 20:07:58 +000014#include "llvm/CodeGen/MachineFunctionPass.h"
15#include "llvm/CodeGen/MachineInstr.h"
Misha Brukmana9f7f6e2003-05-30 20:17:33 +000016#include "llvm/Target/TargetMachine.h"
Misha Brukmanf86aaa82003-06-02 04:12:39 +000017#include "llvm/Target/TargetData.h"
Chris Lattner556d89d2003-08-01 22:19:03 +000018#include "Support/Debug.h"
Misha Brukmanf86aaa82003-06-02 04:12:39 +000019#include "Support/hash_set"
Misha Brukman3de36f52003-05-27 20:07:58 +000020#include "SparcInternals.h"
Misha Brukman0cc640e2003-05-27 21:45:05 +000021#include "SparcV9CodeEmitter.h"
Misha Brukman3de36f52003-05-27 20:07:58 +000022
23bool UltraSparc::addPassesToEmitMachineCode(PassManager &PM,
24 MachineCodeEmitter &MCE) {
Misha Brukman8f122222003-06-06 00:26:11 +000025 MachineCodeEmitter *M = &MCE;
Misha Brukmande07be32003-06-06 04:41:22 +000026 DEBUG(M = MachineCodeEmitter::createFilePrinterEmitter(MCE));
Misha Brukmana2196c12003-06-04 20:01:13 +000027 PM.add(new SparcV9CodeEmitter(*this, *M));
Misha Brukmandcbe7122003-05-31 06:26:06 +000028 PM.add(createMachineCodeDestructionPass()); // Free stuff no longer needed
Misha Brukman3de36f52003-05-27 20:07:58 +000029 return false;
30}
31
Misha Brukmanf86aaa82003-06-02 04:12:39 +000032namespace {
33 class JITResolver {
Misha Brukmana2196c12003-06-04 20:01:13 +000034 SparcV9CodeEmitter &SparcV9;
Misha Brukmanf86aaa82003-06-02 04:12:39 +000035 MachineCodeEmitter &MCE;
36
37 // LazyCodeGenMap - Keep track of call sites for functions that are to be
38 // lazily resolved.
Misha Brukmana2196c12003-06-04 20:01:13 +000039 std::map<uint64_t, Function*> LazyCodeGenMap;
Misha Brukmanf86aaa82003-06-02 04:12:39 +000040
41 // LazyResolverMap - Keep track of the lazy resolver created for a
42 // particular function so that we can reuse them if necessary.
Misha Brukmana2196c12003-06-04 20:01:13 +000043 std::map<Function*, uint64_t> LazyResolverMap;
Misha Brukmanf86aaa82003-06-02 04:12:39 +000044 public:
Misha Brukmana2196c12003-06-04 20:01:13 +000045 JITResolver(SparcV9CodeEmitter &V9,
46 MachineCodeEmitter &mce) : SparcV9(V9), MCE(mce) {}
47 uint64_t getLazyResolver(Function *F);
48 uint64_t addFunctionReference(uint64_t Address, Function *F);
49
50 // Utility functions for accessing data from static callback
51 uint64_t getCurrentPCValue() {
52 return MCE.getCurrentPCValue();
53 }
54 unsigned getBinaryCodeForInstr(MachineInstr &MI) {
55 return SparcV9.getBinaryCodeForInstr(MI);
56 }
57
Misha Brukmanf47d9c22003-06-05 20:52:06 +000058 inline uint64_t insertFarJumpAtAddr(int64_t Value, uint64_t Addr);
59
Misha Brukmanf86aaa82003-06-02 04:12:39 +000060 private:
Misha Brukmana2196c12003-06-04 20:01:13 +000061 uint64_t emitStubForFunction(Function *F);
Misha Brukmanf86aaa82003-06-02 04:12:39 +000062 static void CompilationCallback();
Misha Brukmana2196c12003-06-04 20:01:13 +000063 uint64_t resolveFunctionReference(uint64_t RetAddr);
Misha Brukmanf47d9c22003-06-05 20:52:06 +000064
Misha Brukmanf86aaa82003-06-02 04:12:39 +000065 };
66
67 JITResolver *TheJITResolver;
68}
69
70/// addFunctionReference - This method is called when we need to emit the
71/// address of a function that has not yet been emitted, so we don't know the
72/// address. Instead, we emit a call to the CompilationCallback method, and
73/// keep track of where we are.
74///
Misha Brukmana2196c12003-06-04 20:01:13 +000075uint64_t JITResolver::addFunctionReference(uint64_t Address, Function *F) {
Misha Brukmanf86aaa82003-06-02 04:12:39 +000076 LazyCodeGenMap[Address] = F;
77 return (intptr_t)&JITResolver::CompilationCallback;
78}
79
Misha Brukmana2196c12003-06-04 20:01:13 +000080uint64_t JITResolver::resolveFunctionReference(uint64_t RetAddr) {
81 std::map<uint64_t, Function*>::iterator I = LazyCodeGenMap.find(RetAddr);
Misha Brukmanf86aaa82003-06-02 04:12:39 +000082 assert(I != LazyCodeGenMap.end() && "Not in map!");
83 Function *F = I->second;
84 LazyCodeGenMap.erase(I);
85 return MCE.forceCompilationOf(F);
86}
87
Misha Brukmana2196c12003-06-04 20:01:13 +000088uint64_t JITResolver::getLazyResolver(Function *F) {
89 std::map<Function*, uint64_t>::iterator I = LazyResolverMap.lower_bound(F);
Misha Brukmanf86aaa82003-06-02 04:12:39 +000090 if (I != LazyResolverMap.end() && I->first == F) return I->second;
91
92//std::cerr << "Getting lazy resolver for : " << ((Value*)F)->getName() << "\n";
93
Misha Brukmana2196c12003-06-04 20:01:13 +000094 uint64_t Stub = emitStubForFunction(F);
Misha Brukmanf86aaa82003-06-02 04:12:39 +000095 LazyResolverMap.insert(I, std::make_pair(F, Stub));
96 return Stub;
97}
98
Misha Brukmanf47d9c22003-06-05 20:52:06 +000099uint64_t JITResolver::insertFarJumpAtAddr(int64_t Target, uint64_t Addr) {
100
101 static const unsigned i1 = SparcIntRegClass::i1, i2 = SparcIntRegClass::i2,
102 i7 = SparcIntRegClass::i7,
103 o6 = SparcIntRegClass::o6, g0 = SparcIntRegClass::g0;
104
105 //
106 // Save %i1, %i2 to the stack so we can form a 64-bit constant in %i2
107 //
108
109 // stx %i1, [%sp + 2119] ;; save %i1 to the stack, used as temp
110 MachineInstr *STX = BuildMI(V9::STXi, 3).addReg(i1).addReg(o6).addSImm(2119);
111 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*STX);
112 delete STX;
113 Addr += 4;
114
115 // stx %i2, [%sp + 2127] ;; save %i2 to the stack
116 STX = BuildMI(V9::STXi, 3).addReg(i2).addReg(o6).addSImm(2127);
117 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*STX);
118 delete STX;
119 Addr += 4;
120
121 //
122 // Get address to branch into %i2, using %i1 as a temporary
123 //
124
125 // sethi %uhi(Target), %i1 ;; get upper 22 bits of Target into %i1
126 MachineInstr *SH = BuildMI(V9::SETHI, 2).addSImm(Target >> 42).addReg(i1);
127 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*SH);
128 delete SH;
129 Addr += 4;
130
131 // or %i1, %ulo(Target), %i1 ;; get 10 lower bits of upper word into %1
132 MachineInstr *OR = BuildMI(V9::ORi, 3)
133 .addReg(i1).addSImm((Target >> 32) & 0x03ff).addReg(i1);
134 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*OR);
135 delete OR;
136 Addr += 4;
137
138 // sllx %i1, 32, %i1 ;; shift those 10 bits to the upper word
139 MachineInstr *SL = BuildMI(V9::SLLXi6, 3).addReg(i1).addSImm(32).addReg(i1);
140 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*SL);
141 delete SL;
142 Addr += 4;
143
144 // sethi %hi(Target), %i2 ;; extract bits 10-31 into the dest reg
145 SH = BuildMI(V9::SETHI, 2).addSImm((Target >> 10) & 0x03fffff).addReg(i2);
146 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*SH);
147 delete SH;
148 Addr += 4;
149
150 // or %i1, %i2, %i2 ;; get upper word (in %i1) into %i2
151 OR = BuildMI(V9::ORr, 3).addReg(i1).addReg(i2).addReg(i2);
152 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*OR);
153 delete OR;
154 Addr += 4;
155
156 // or %i2, %lo(Target), %i2 ;; get lowest 10 bits of Target into %i2
157 OR = BuildMI(V9::ORi, 3).addReg(i2).addSImm(Target & 0x03ff).addReg(i2);
158 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*OR);
159 delete OR;
160 Addr += 4;
161
162 // ldx [%sp + 2119], %i1 ;; restore %i1 -> 2119 = BIAS(2047) + 72
163 MachineInstr *LDX = BuildMI(V9::LDXi, 3).addReg(o6).addSImm(2119).addReg(i1);
164 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*LDX);
165 delete LDX;
166 Addr += 4;
167
168 // jmpl %i2, %g0, %g0 ;; indirect branch on %i2
169 MachineInstr *J = BuildMI(V9::JMPLRETr, 3).addReg(i2).addReg(g0).addReg(g0);
170 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*J);
171 delete J;
172 Addr += 4;
173
174 // ldx [%sp + 2127], %i2 ;; restore %i2 -> 2127 = BIAS(2047) + 80
175 LDX = BuildMI(V9::LDXi, 3).addReg(o6).addSImm(2127).addReg(i2);
176 *((unsigned*)(intptr_t)Addr) = getBinaryCodeForInstr(*LDX);
177 delete LDX;
178 Addr += 4;
179
180 return Addr;
181}
182
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000183void JITResolver::CompilationCallback() {
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000184 uint64_t CameFrom = (uint64_t)(intptr_t)__builtin_return_address(0);
185 int64_t Target = (int64_t)TheJITResolver->resolveFunctionReference(CameFrom);
Misha Brukman8f122222003-06-06 00:26:11 +0000186 DEBUG(std::cerr << "In callback! Addr=0x" << std::hex << CameFrom << "\n");
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000187
188 // Rewrite the call target... so that we don't fault every time we execute
189 // the call.
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000190#if 0
Misha Brukmana2196c12003-06-04 20:01:13 +0000191 int64_t RealCallTarget = (int64_t)
192 ((NewVal - TheJITResolver->getCurrentPCValue()) >> 4);
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000193 if (RealCallTarget >= (1<<22) || RealCallTarget <= -(1<<22)) {
194 std::cerr << "Address out of bounds for 22bit BA: " << RealCallTarget<<"\n";
195 abort();
196 }
197#endif
198
199 //uint64_t CurrPC = TheJITResolver->getCurrentPCValue();
200 // we will insert 9 instructions before we do the actual jump
201 //int64_t NewTarget = (NewVal - 9*4 - InstAddr) >> 2;
202
203 static const unsigned i1 = SparcIntRegClass::i1, i2 = SparcIntRegClass::i2,
204 i7 = SparcIntRegClass::i7, o6 = SparcIntRegClass::o6,
205 o7 = SparcIntRegClass::o7, g0 = SparcIntRegClass::g0;
206
207 // Subtract 4 to overwrite the 'save' that's there now
208 uint64_t InstAddr = CameFrom-4;
209
210 InstAddr = TheJITResolver->insertFarJumpAtAddr(Target, InstAddr);
211
212 // CODE SHOULD NEVER GO PAST THIS LOAD!! The real function should return to
213 // the original caller, not here!!
214
215 // FIXME: add call 0 to make sure?!?
216
217 // =============== THE REAL STUB ENDS HERE =========================
218
219 // What follows below is one-time restore code, because this callback may be
220 // changing registers in unpredictible ways. However, since it is executed
221 // only once per function (after the function is resolved, the callback is no
222 // longer in the path), this has to be done only once.
223 //
224 // Thus, it is after the regular stub code. The call back returns to THIS
225 // point, but every other call to the target function will execute the code
226 // above. Hence, this code is one-time use.
227
228 uint64_t OneTimeRestore = InstAddr;
229
230 // restore %g0, 0, %g0
231 //MachineInstr *R = BuildMI(V9::RESTOREi, 3).addMReg(g0).addSImm(0)
232 // .addMReg(g0, MOTy::Def);
233 //*((unsigned*)(intptr_t)InstAddr)=TheJITResolver->getBinaryCodeForInstr(*R);
234 //delete R;
235
236 // FIXME: BuildMI() above crashes. Encode the instruction directly.
237 // restore %g0, 0, %g0
238 *((unsigned*)(intptr_t)InstAddr) = 0x81e82000U;
239 InstAddr += 4;
240
241 InstAddr = TheJITResolver->insertFarJumpAtAddr(Target, InstAddr);
242
243 // FIXME: if the target function is close enough to fit into the 19bit disp of
244 // BA, we should use this version, as its much cheaper to generate.
245 /*
246 MachineInstr *MI = BuildMI(V9::BA, 1).addSImm(RealCallTarget);
247 *((unsigned*)(intptr_t)InstAddr) = TheJITResolver->getBinaryCodeForInstr(*MI);
Misha Brukmana2196c12003-06-04 20:01:13 +0000248 delete MI;
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000249 InstAddr += 4;
250
251 // Add another NOP
252 MachineInstr *Nop = BuildMI(V9::NOP, 0);
253 *((unsigned*)(intptr_t)InstAddr)=TheJITResolver->getBinaryCodeForInstr(*Nop);
254 delete Nop;
255 InstAddr += 4;
256
257 MachineInstr *BA = BuildMI(V9::BA, 1).addSImm(RealCallTarget-2);
258 *((unsigned*)(intptr_t)InstAddr) = TheJITResolver->getBinaryCodeForInstr(*BA);
259 delete BA;
260 */
261
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000262 // Change the return address to reexecute the call instruction...
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000263 // The return address is really %o7, but will disappear after this function
264 // returns, and the register windows are rotated away.
265#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
266 __asm__ __volatile__ ("or %%g0, %0, %%i7" : : "r" (OneTimeRestore-8));
267#endif
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000268}
269
270/// emitStubForFunction - This method is used by the JIT when it needs to emit
271/// the address of a function for a function whose code has not yet been
272/// generated. In order to do this, it generates a stub which jumps to the lazy
273/// function compiler, which will eventually get fixed to call the function
274/// directly.
275///
Misha Brukmana2196c12003-06-04 20:01:13 +0000276uint64_t JITResolver::emitStubForFunction(Function *F) {
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000277 MCE.startFunctionStub(*F, 6);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000278
Misha Brukman8f122222003-06-06 00:26:11 +0000279 DEBUG(std::cerr << "Emitting stub at addr: 0x"
280 << std::hex << MCE.getCurrentPCValue() << "\n");
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000281
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000282 unsigned o6 = SparcIntRegClass::o6;
283 // save %sp, -192, %sp
284 MachineInstr *SV = BuildMI(V9::SAVEi, 3).addReg(o6).addSImm(-192).addReg(o6);
285 SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*SV));
286 delete SV;
Misha Brukmana2196c12003-06-04 20:01:13 +0000287
288 int64_t CurrPC = MCE.getCurrentPCValue();
289 int64_t Addr = (int64_t)addFunctionReference(CurrPC, F);
290 int64_t CallTarget = (Addr-CurrPC) >> 2;
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000291 if (CallTarget >= (1 << 30) || CallTarget <= -(1 << 30)) {
Misha Brukmana1f1fea2003-07-29 19:00:58 +0000292 SparcV9.emitFarCall(Addr);
293 } else {
294 // call CallTarget ;; invoke the callback
295 MachineInstr *Call = BuildMI(V9::CALL, 1).addSImm(CallTarget);
296 SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*Call));
297 delete Call;
Misha Brukmana2196c12003-06-04 20:01:13 +0000298
Misha Brukmana1f1fea2003-07-29 19:00:58 +0000299 // nop ;; call delay slot
300 MachineInstr *Nop = BuildMI(V9::NOP, 0);
301 SparcV9.emitWord(SparcV9.getBinaryCodeForInstr(*Nop));
302 delete Nop;
303 }
Misha Brukmana2196c12003-06-04 20:01:13 +0000304
305 SparcV9.emitWord(0xDEADBEEF); // marker so that we know it's really a stub
306 return (intptr_t)MCE.finishFunctionStub(*F);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000307}
308
309
Misha Brukmana2196c12003-06-04 20:01:13 +0000310SparcV9CodeEmitter::SparcV9CodeEmitter(TargetMachine &tm,
311 MachineCodeEmitter &M): TM(tm), MCE(M)
312{
313 TheJITResolver = new JITResolver(*this, M);
314}
315
316SparcV9CodeEmitter::~SparcV9CodeEmitter() {
317 delete TheJITResolver;
318}
319
320void SparcV9CodeEmitter::emitWord(unsigned Val) {
Misha Brukman3de36f52003-05-27 20:07:58 +0000321 // Output the constant in big endian byte order...
322 unsigned byteVal;
Misha Brukmana2196c12003-06-04 20:01:13 +0000323 for (int i = 3; i >= 0; --i) {
Misha Brukman3de36f52003-05-27 20:07:58 +0000324 byteVal = Val >> 8*i;
Misha Brukmana2196c12003-06-04 20:01:13 +0000325 MCE.emitByte(byteVal & 255);
Misha Brukmana9f7f6e2003-05-30 20:17:33 +0000326 }
Misha Brukmana9f7f6e2003-05-30 20:17:33 +0000327}
328
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000329unsigned
Misha Brukman173e2502003-07-14 23:26:03 +0000330SparcV9CodeEmitter::getRealRegNum(unsigned fakeReg,
Misha Brukman9cedd432003-07-03 18:36:47 +0000331 MachineInstr &MI) {
Misha Brukman173e2502003-07-14 23:26:03 +0000332 const TargetRegInfo &RI = TM.getRegInfo();
333 unsigned regClass, regType = RI.getRegType(fakeReg);
334 // At least map fakeReg into its class
335 fakeReg = RI.getClassRegNum(fakeReg, regClass);
336
Misha Brukman9cedd432003-07-03 18:36:47 +0000337 switch (regClass) {
338 case UltraSparcRegInfo::IntRegClassID: {
339 // Sparc manual, p31
340 static const unsigned IntRegMap[] = {
341 // "o0", "o1", "o2", "o3", "o4", "o5", "o7",
342 8, 9, 10, 11, 12, 13, 15,
343 // "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
344 16, 17, 18, 19, 20, 21, 22, 23,
345 // "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
346 24, 25, 26, 27, 28, 29, 30, 31,
347 // "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
348 0, 1, 2, 3, 4, 5, 6, 7,
349 // "o6"
350 14
351 };
352
353 return IntRegMap[fakeReg];
354 break;
355 }
356 case UltraSparcRegInfo::FloatRegClassID: {
357 DEBUG(std::cerr << "FP reg: " << fakeReg << "\n");
Misha Brukman173e2502003-07-14 23:26:03 +0000358 if (regType == UltraSparcRegInfo::FPSingleRegType) {
359 // only numbered 0-31, hence can already fit into 5 bits (and 6)
360 DEBUG(std::cerr << "FP single reg, returning: " << fakeReg << "\n");
361 } else if (regType == UltraSparcRegInfo::FPDoubleRegType) {
362 // FIXME: This assumes that we only have 5-bit register fiels!
363 // From Sparc Manual, page 40.
364 // The bit layout becomes: b[4], b[3], b[2], b[1], b[5]
365 fakeReg |= (fakeReg >> 5) & 1;
366 fakeReg &= 0x1f;
367 DEBUG(std::cerr << "FP double reg, returning: " << fakeReg << "\n");
368 }
Misha Brukman9cedd432003-07-03 18:36:47 +0000369 return fakeReg;
370 }
371 case UltraSparcRegInfo::IntCCRegClassID: {
Misha Brukmandfbfc572003-07-16 20:30:40 +0000372 /* xcc, icc, ccr */
373 static const unsigned IntCCReg[] = { 6, 4, 2 };
Misha Brukman9cedd432003-07-03 18:36:47 +0000374
Misha Brukmandfbfc572003-07-16 20:30:40 +0000375 assert(fakeReg < sizeof(IntCCReg)/sizeof(IntCCReg[0])
376 && "CC register out of bounds for IntCCReg map");
377 DEBUG(std::cerr << "IntCC reg: " << IntCCReg[fakeReg] << "\n");
378 return IntCCReg[fakeReg];
Misha Brukman9cedd432003-07-03 18:36:47 +0000379 }
380 case UltraSparcRegInfo::FloatCCRegClassID: {
381 /* These are laid out %fcc0 - %fcc3 => 0 - 3, so are correct */
382 DEBUG(std::cerr << "FP CC reg: " << fakeReg << "\n");
383 return fakeReg;
384 }
385 default:
386 assert(0 && "Invalid unified register number in getRegType");
387 return fakeReg;
388 }
389}
390
391
Misha Brukman07d45162003-07-15 19:09:43 +0000392// WARNING: if the call used the delay slot to do meaningful work, that's not
393// being accounted for, and the behavior will be incorrect!!
394inline void SparcV9CodeEmitter::emitFarCall(uint64_t Target) {
395 static const unsigned i1 = SparcIntRegClass::i1, i2 = SparcIntRegClass::i2,
Misha Brukmana1f1fea2003-07-29 19:00:58 +0000396 i7 = SparcIntRegClass::i7, o6 = SparcIntRegClass::o6,
397 o7 = SparcIntRegClass::o7, g0 = SparcIntRegClass::g0;
Misha Brukman07d45162003-07-15 19:09:43 +0000398
399 //
400 // Save %i1, %i2 to the stack so we can form a 64-bit constant in %i2
401 //
402
403 // stx %i1, [%sp + 2119] ;; save %i1 to the stack, used as temp
404 MachineInstr *STX = BuildMI(V9::STXi, 3).addReg(i1).addReg(o6).addSImm(2119);
405 emitWord(getBinaryCodeForInstr(*STX));
406 delete STX;
407
408 // stx %i2, [%sp + 2127] ;; save %i2 to the stack
409 STX = BuildMI(V9::STXi, 3).addReg(i2).addReg(o6).addSImm(2127);
410 emitWord(getBinaryCodeForInstr(*STX));
411 delete STX;
412
413 //
414 // Get address to branch into %i2, using %i1 as a temporary
415 //
416
417 // sethi %uhi(Target), %i1 ;; get upper 22 bits of Target into %i1
418 MachineInstr *SH = BuildMI(V9::SETHI, 2).addSImm(Target >> 42).addReg(i1);
419 emitWord(getBinaryCodeForInstr(*SH));
420 delete SH;
421
422 // or %i1, %ulo(Target), %i1 ;; get 10 lower bits of upper word into %1
423 MachineInstr *OR = BuildMI(V9::ORi, 3)
424 .addReg(i1).addSImm((Target >> 32) & 0x03ff).addReg(i1);
425 emitWord(getBinaryCodeForInstr(*OR));
426 delete OR;
427
428 // sllx %i1, 32, %i1 ;; shift those 10 bits to the upper word
429 MachineInstr *SL = BuildMI(V9::SLLXi6, 3).addReg(i1).addSImm(32).addReg(i1);
430 emitWord(getBinaryCodeForInstr(*SL));
431 delete SL;
432
433 // sethi %hi(Target), %i2 ;; extract bits 10-31 into the dest reg
434 SH = BuildMI(V9::SETHI, 2).addSImm((Target >> 10) & 0x03fffff).addReg(i2);
435 emitWord(getBinaryCodeForInstr(*SH));
436 delete SH;
437
438 // or %i1, %i2, %i2 ;; get upper word (in %i1) into %i2
439 OR = BuildMI(V9::ORr, 3).addReg(i1).addReg(i2).addReg(i2);
440 emitWord(getBinaryCodeForInstr(*OR));
441 delete OR;
442
443 // or %i2, %lo(Target), %i2 ;; get lowest 10 bits of Target into %i2
444 OR = BuildMI(V9::ORi, 3).addReg(i2).addSImm(Target & 0x03ff).addReg(i2);
445 emitWord(getBinaryCodeForInstr(*OR));
446 delete OR;
447
448 // ldx [%sp + 2119], %i1 ;; restore %i1 -> 2119 = BIAS(2047) + 72
449 MachineInstr *LDX = BuildMI(V9::LDXi, 3).addReg(o6).addSImm(2119).addReg(i1);
450 emitWord(getBinaryCodeForInstr(*LDX));
451 delete LDX;
452
Misha Brukmana1f1fea2003-07-29 19:00:58 +0000453 // jmpl %i2, %g0, %o7 ;; indirect call on %i2
454 MachineInstr *J = BuildMI(V9::JMPLRETr, 3).addReg(i2).addReg(g0).addReg(o7);
Misha Brukman07d45162003-07-15 19:09:43 +0000455 emitWord(getBinaryCodeForInstr(*J));
456 delete J;
457
458 // ldx [%sp + 2127], %i2 ;; restore %i2 -> 2127 = BIAS(2047) + 80
459 LDX = BuildMI(V9::LDXi, 3).addReg(o6).addSImm(2127).addReg(i2);
460 emitWord(getBinaryCodeForInstr(*LDX));
461 delete LDX;
462}
463
464
Misha Brukmana9f7f6e2003-05-30 20:17:33 +0000465int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI,
466 MachineOperand &MO) {
Brian Gaekec3eaa892003-06-02 02:13:26 +0000467 int64_t rv = 0; // Return value; defaults to 0 for unhandled cases
468 // or things that get fixed up later by the JIT.
469
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000470 if (MO.isVirtualRegister()) {
Misha Brukman33394592003-06-06 03:35:37 +0000471 std::cerr << "ERROR: virtual register found in machine code.\n";
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000472 abort();
473 } else if (MO.isPCRelativeDisp()) {
Misha Brukman8f122222003-06-06 00:26:11 +0000474 DEBUG(std::cerr << "PCRelativeDisp: ");
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000475 Value *V = MO.getVRegValue();
476 if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
Misha Brukman8f122222003-06-06 00:26:11 +0000477 DEBUG(std::cerr << "Saving reference to BB (VReg)\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000478 unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000479 BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
Misha Brukmana2196c12003-06-04 20:01:13 +0000480 } else if (const Constant *C = dyn_cast<Constant>(V)) {
481 if (ConstantMap.find(C) != ConstantMap.end()) {
482 rv = (int64_t)MCE.getConstantPoolEntryAddress(ConstantMap[C]);
Misha Brukman8f122222003-06-06 00:26:11 +0000483 DEBUG(std::cerr << "const: 0x" << std::hex << rv << "\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000484 } else {
Misha Brukman33394592003-06-06 03:35:37 +0000485 std::cerr << "ERROR: constant not in map:" << MO << "\n";
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000486 abort();
487 }
Misha Brukmana2196c12003-06-04 20:01:13 +0000488 } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
489 // same as MO.isGlobalAddress()
Misha Brukman8f122222003-06-06 00:26:11 +0000490 DEBUG(std::cerr << "GlobalValue: ");
Misha Brukmana2196c12003-06-04 20:01:13 +0000491 // external function calls, etc.?
492 if (Function *F = dyn_cast<Function>(GV)) {
Misha Brukman8f122222003-06-06 00:26:11 +0000493 DEBUG(std::cerr << "Function: ");
Misha Brukmana2196c12003-06-04 20:01:13 +0000494 if (F->isExternal()) {
495 // Sparc backend broken: this MO should be `ExternalSymbol'
496 rv = (int64_t)MCE.getGlobalValueAddress(F->getName());
497 } else {
498 rv = (int64_t)MCE.getGlobalValueAddress(F);
499 }
500 if (rv == 0) {
Misha Brukman8f122222003-06-06 00:26:11 +0000501 DEBUG(std::cerr << "not yet generated\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000502 // Function has not yet been code generated!
503 TheJITResolver->addFunctionReference(MCE.getCurrentPCValue(), F);
504 // Delayed resolution...
505 rv = TheJITResolver->getLazyResolver(F);
506 } else {
Misha Brukman8f122222003-06-06 00:26:11 +0000507 DEBUG(std::cerr << "already generated: 0x" << std::hex << rv << "\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000508 }
509 } else {
Misha Brukman33394592003-06-06 03:35:37 +0000510 rv = (int64_t)MCE.getGlobalValueAddress(GV);
Misha Brukmande07be32003-06-06 04:41:22 +0000511 if (rv == 0) {
512 if (Constant *C = ConstantPointerRef::get(GV)) {
513 if (ConstantMap.find(C) != ConstantMap.end()) {
514 rv = MCE.getConstantPoolEntryAddress(ConstantMap[C]);
515 } else {
Misha Brukman8631ac42003-06-06 09:53:28 +0000516 std::cerr << "Constant: 0x" << std::hex << (intptr_t)C
Misha Brukmande07be32003-06-06 04:41:22 +0000517 << ", " << *V << " not found in ConstantMap!\n";
518 abort();
519 }
520 }
521 }
522 DEBUG(std::cerr << "Global addr: " << rv << "\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000523 }
524 // The real target of the call is Addr = PC + (rv * 4)
525 // So undo that: give the instruction (Addr - PC) / 4
526 if (MI.getOpcode() == V9::CALL) {
527 int64_t CurrPC = MCE.getCurrentPCValue();
Misha Brukman8f122222003-06-06 00:26:11 +0000528 DEBUG(std::cerr << "rv addr: 0x" << std::hex << rv << "\n"
529 << "curr PC: 0x" << CurrPC << "\n");
Misha Brukman07d45162003-07-15 19:09:43 +0000530 int64_t CallInstTarget = (rv - CurrPC) >> 2;
531 if (CallInstTarget >= (1<<29) || CallInstTarget <= -(1<<29)) {
532 DEBUG(std::cerr << "Making far call!\n");
533 // addresss is out of bounds for the 30-bit call,
534 // make an indirect jump-and-link
535 emitFarCall(rv);
536 // this invalidates the instruction so that the call with an incorrect
537 // address will not be emitted
538 rv = 0;
539 } else {
540 // The call fits into 30 bits, so just return the corrected address
541 rv = CallInstTarget;
Misha Brukmana2196c12003-06-04 20:01:13 +0000542 }
Misha Brukman8f122222003-06-06 00:26:11 +0000543 DEBUG(std::cerr << "returning addr: 0x" << rv << "\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000544 }
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000545 } else {
546 std::cerr << "ERROR: PC relative disp unhandled:" << MO << "\n";
547 abort();
548 }
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000549 } else if (MO.isPhysicalRegister() ||
550 MO.getType() == MachineOperand::MO_CCRegister)
551 {
Misha Brukman9cedd432003-07-03 18:36:47 +0000552 // This is necessary because the Sparc backend doesn't actually lay out
553 // registers in the real fashion -- it skips those that it chooses not to
554 // allocate, i.e. those that are the FP, SP, etc.
Misha Brukman173e2502003-07-14 23:26:03 +0000555 unsigned fakeReg = MO.getAllocatedRegNum();
556 unsigned realRegByClass = getRealRegNum(fakeReg, MI);
557 DEBUG(std::cerr << MO << ": Reg[" << std::dec << fakeReg << "] => "
Misha Brukmandfbfc572003-07-16 20:30:40 +0000558 << realRegByClass << " (LLC: "
559 << TM.getRegInfo().getUnifiedRegName(fakeReg) << ")\n");
Misha Brukman9cedd432003-07-03 18:36:47 +0000560 rv = realRegByClass;
Misha Brukman3de36f52003-05-27 20:07:58 +0000561 } else if (MO.isImmediate()) {
Brian Gaekec3eaa892003-06-02 02:13:26 +0000562 rv = MO.getImmedValue();
Misha Brukman8f122222003-06-06 00:26:11 +0000563 DEBUG(std::cerr << "immed: " << rv << "\n");
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000564 } else if (MO.isGlobalAddress()) {
Misha Brukman8f122222003-06-06 00:26:11 +0000565 DEBUG(std::cerr << "GlobalAddress: not PC-relative\n");
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000566 rv = (int64_t)
567 (intptr_t)getGlobalAddress(cast<GlobalValue>(MO.getVRegValue()),
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000568 MI, MO.isPCRelative());
Misha Brukmana9f7f6e2003-05-30 20:17:33 +0000569 } else if (MO.isMachineBasicBlock()) {
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000570 // Duplicate code of the above case for VirtualRegister, BasicBlock...
571 // It should really hit this case, but Sparc backend uses VRegs instead
Misha Brukman8f122222003-06-06 00:26:11 +0000572 DEBUG(std::cerr << "Saving reference to MBB\n");
Chris Lattner6856d112003-07-26 23:04:00 +0000573 const BasicBlock *BB = MO.getMachineBasicBlock()->getBasicBlock();
Misha Brukmana2196c12003-06-04 20:01:13 +0000574 unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000575 BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
Misha Brukmana9f7f6e2003-05-30 20:17:33 +0000576 } else if (MO.isExternalSymbol()) {
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000577 // Sparc backend doesn't generate this (yet...)
578 std::cerr << "ERROR: External symbol unhandled: " << MO << "\n";
579 abort();
580 } else if (MO.isFrameIndex()) {
581 // Sparc backend doesn't generate this (yet...)
582 int FrameIndex = MO.getFrameIndex();
583 std::cerr << "ERROR: Frame index unhandled.\n";
584 abort();
585 } else if (MO.isConstantPoolIndex()) {
586 // Sparc backend doesn't generate this (yet...)
587 std::cerr << "ERROR: Constant Pool index unhandled.\n";
588 abort();
Misha Brukman3de36f52003-05-27 20:07:58 +0000589 } else {
Misha Brukmana9f7f6e2003-05-30 20:17:33 +0000590 std::cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000591 abort();
Brian Gaekec3eaa892003-06-02 02:13:26 +0000592 }
593
594 // Finally, deal with the various bitfield-extracting functions that
595 // are used in SPARC assembly. (Some of these make no sense in combination
596 // with some of the above; we'll trust that the instruction selector
597 // will not produce nonsense, and not check for valid combinations here.)
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000598 if (MO.opLoBits32()) { // %lo(val) == %lo() in Sparc ABI doc
Brian Gaekec3eaa892003-06-02 02:13:26 +0000599 return rv & 0x03ff;
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000600 } else if (MO.opHiBits32()) { // %lm(val) == %hi() in Sparc ABI doc
Brian Gaekec3eaa892003-06-02 02:13:26 +0000601 return (rv >> 10) & 0x03fffff;
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000602 } else if (MO.opLoBits64()) { // %hm(val) == %ulo() in Sparc ABI doc
Brian Gaekec3eaa892003-06-02 02:13:26 +0000603 return (rv >> 32) & 0x03ff;
Misha Brukmanf47d9c22003-06-05 20:52:06 +0000604 } else if (MO.opHiBits64()) { // %hh(val) == %uhi() in Sparc ABI doc
Brian Gaekec3eaa892003-06-02 02:13:26 +0000605 return rv >> 42;
606 } else { // (unadorned) val
607 return rv;
Misha Brukman3de36f52003-05-27 20:07:58 +0000608 }
609}
610
611unsigned SparcV9CodeEmitter::getValueBit(int64_t Val, unsigned bit) {
612 Val >>= bit;
613 return (Val & 1);
614}
615
Misha Brukman3de36f52003-05-27 20:07:58 +0000616bool SparcV9CodeEmitter::runOnMachineFunction(MachineFunction &MF) {
Misha Brukmana2196c12003-06-04 20:01:13 +0000617 MCE.startFunction(MF);
Misha Brukman8f122222003-06-06 00:26:11 +0000618 DEBUG(std::cerr << "Starting function " << MF.getFunction()->getName()
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000619 << ", address: " << "0x" << std::hex
Misha Brukman8f122222003-06-06 00:26:11 +0000620 << (long)MCE.getCurrentPCValue() << "\n");
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000621
Misha Brukmana2196c12003-06-04 20:01:13 +0000622 // The Sparc backend does not use MachineConstantPool;
623 // instead, it has its own constant pool implementation.
624 // We create a new MachineConstantPool here to be compatible with the emitter.
625 MachineConstantPool MCP;
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000626 const hash_set<const Constant*> &pool = MF.getInfo()->getConstantPoolValues();
627 for (hash_set<const Constant*>::const_iterator I = pool.begin(),
628 E = pool.end(); I != E; ++I)
629 {
Misha Brukmana2196c12003-06-04 20:01:13 +0000630 Constant *C = (Constant*)*I;
631 unsigned idx = MCP.getConstantPoolIndex(C);
Misha Brukman9cedd432003-07-03 18:36:47 +0000632 DEBUG(std::cerr << "Constant[" << idx << "] = 0x" << (intptr_t)C << "\n");
Misha Brukmana2196c12003-06-04 20:01:13 +0000633 ConstantMap[C] = idx;
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000634 }
Misha Brukmana2196c12003-06-04 20:01:13 +0000635 MCE.emitConstantPool(&MCP);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000636
Misha Brukman3de36f52003-05-27 20:07:58 +0000637 for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
638 emitBasicBlock(*I);
Misha Brukmana2196c12003-06-04 20:01:13 +0000639 MCE.finishFunction(MF);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000640
Misha Brukman9cedd432003-07-03 18:36:47 +0000641 DEBUG(std::cerr << "Finishing fn " << MF.getFunction()->getName() << "\n");
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000642 ConstantMap.clear();
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000643
644 // Resolve branches to BasicBlocks for the entire function
645 for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) {
646 long Location = BBLocations[BBRefs[i].first];
647 unsigned *Ref = BBRefs[i].second.first;
648 MachineInstr *MI = BBRefs[i].second.second;
Misha Brukman9cedd432003-07-03 18:36:47 +0000649 DEBUG(std::cerr << "Fixup @ " << std::hex << Ref << " to 0x" << Location
650 << " in instr: " << std::dec << *MI);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000651 for (unsigned ii = 0, ee = MI->getNumOperands(); ii != ee; ++ii) {
652 MachineOperand &op = MI->getOperand(ii);
653 if (op.isPCRelativeDisp()) {
654 // the instruction's branch target is made such that it branches to
Misha Brukman9cedd432003-07-03 18:36:47 +0000655 // PC + (branchTarget * 4), so undo that arithmetic here:
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000656 // Location is the target of the branch
657 // Ref is the location of the instruction, and hence the PC
Misha Brukman9cedd432003-07-03 18:36:47 +0000658 int64_t branchTarget = (Location - (long)Ref) >> 2;
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000659 // Save the flags.
660 bool loBits32=false, hiBits32=false, loBits64=false, hiBits64=false;
661 if (op.opLoBits32()) { loBits32=true; }
662 if (op.opHiBits32()) { hiBits32=true; }
663 if (op.opLoBits64()) { loBits64=true; }
664 if (op.opHiBits64()) { hiBits64=true; }
665 MI->SetMachineOperandConst(ii, MachineOperand::MO_SignExtendedImmed,
666 branchTarget);
667 if (loBits32) { MI->setOperandLo32(ii); }
668 else if (hiBits32) { MI->setOperandHi32(ii); }
669 else if (loBits64) { MI->setOperandLo64(ii); }
670 else if (hiBits64) { MI->setOperandHi64(ii); }
Misha Brukman8f122222003-06-06 00:26:11 +0000671 DEBUG(std::cerr << "Rewrote BB ref: ");
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000672 unsigned fixedInstr = SparcV9CodeEmitter::getBinaryCodeForInstr(*MI);
673 *Ref = fixedInstr;
674 break;
675 }
676 }
677 }
678 BBRefs.clear();
679 BBLocations.clear();
680
Misha Brukman3de36f52003-05-27 20:07:58 +0000681 return false;
682}
683
684void SparcV9CodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
Misha Brukman0d603452003-05-27 22:41:44 +0000685 currBB = MBB.getBasicBlock();
Misha Brukmana2196c12003-06-04 20:01:13 +0000686 BBLocations[currBB] = MCE.getCurrentPCValue();
Misha Brukman07d45162003-07-15 19:09:43 +0000687 for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){
688 unsigned binCode = getBinaryCodeForInstr(**I);
689 if (binCode == (1 << 30)) {
690 // this is an invalid call: the addr is out of bounds. that means a code
691 // sequence has already been emitted, and this is a no-op
692 DEBUG(std::cerr << "Call supressed: already emitted far call.\n");
693 } else {
694 emitWord(binCode);
695 }
696 }
Misha Brukman3de36f52003-05-27 20:07:58 +0000697}
698
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000699void* SparcV9CodeEmitter::getGlobalAddress(GlobalValue *V, MachineInstr &MI,
700 bool isPCRelative)
701{
702 if (isPCRelative) { // must be a call, this is a major hack!
703 // Try looking up the function to see if it is already compiled!
Misha Brukmana2196c12003-06-04 20:01:13 +0000704 if (void *Addr = (void*)(intptr_t)MCE.getGlobalValueAddress(V)) {
705 intptr_t CurByte = MCE.getCurrentPCValue();
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000706 // The real target of the call is Addr = PC + (target * 4)
707 // CurByte is the PC, Addr we just received
708 return (void*) (((long)Addr - (long)CurByte) >> 2);
709 } else {
710 if (Function *F = dyn_cast<Function>(V)) {
711 // Function has not yet been code generated!
Misha Brukmana2196c12003-06-04 20:01:13 +0000712 TheJITResolver->addFunctionReference(MCE.getCurrentPCValue(),
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000713 cast<Function>(V));
714 // Delayed resolution...
Misha Brukmaneaaf8ad2003-06-02 05:24:46 +0000715 return
716 (void*)(intptr_t)TheJITResolver->getLazyResolver(cast<Function>(V));
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000717
718 } else if (Constant *C = ConstantPointerRef::get(V)) {
719 if (ConstantMap.find(C) != ConstantMap.end()) {
Misha Brukmana2196c12003-06-04 20:01:13 +0000720 return (void*)
721 (intptr_t)MCE.getConstantPoolEntryAddress(ConstantMap[C]);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000722 } else {
723 std::cerr << "Constant: 0x" << std::hex << &*C << std::dec
724 << ", " << *V << " not found in ConstantMap!\n";
725 abort();
726 }
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000727 } else {
728 std::cerr << "Unhandled global: " << *V << "\n";
729 abort();
730 }
731 }
732 } else {
Misha Brukmana2196c12003-06-04 20:01:13 +0000733 return (void*)(intptr_t)MCE.getGlobalValueAddress(V);
Misha Brukmanf86aaa82003-06-02 04:12:39 +0000734 }
735}
736
737
Misha Brukman3de36f52003-05-27 20:07:58 +0000738#include "SparcV9CodeEmitter.inc"