Misha Brukman | 5bf351c | 2003-05-30 20:17:33 +0000 | [diff] [blame] | 1 | //===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===// |
| 2 | // |
John Criswell | 29265fe | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // TODO: Need a description here. |
Misha Brukman | 5bf351c | 2003-05-30 20:17:33 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 13 | |
| 14 | #ifndef SPARCV9CODEEMITTER_H |
| 15 | #define SPARCV9CODEEMITTER_H |
| 16 | |
Misha Brukman | 7975661 | 2003-05-27 22:41:44 +0000 | [diff] [blame] | 17 | #include "llvm/BasicBlock.h" |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/MachineCodeEmitter.h" |
| 19 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Misha Brukman | 5bf351c | 2003-05-30 20:17:33 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetMachine.h" |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 21 | |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame^] | 22 | namespace llvm { |
| 23 | |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 24 | class GlobalValue; |
| 25 | class MachineInstr; |
| 26 | class MachineOperand; |
| 27 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 28 | class SparcV9CodeEmitter : public MachineFunctionPass { |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 29 | TargetMachine &TM; |
| 30 | MachineCodeEmitter &MCE; |
Chris Lattner | 99dbdf7 | 2003-07-26 23:04:00 +0000 | [diff] [blame] | 31 | const BasicBlock *currBB; |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 32 | |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 33 | // Tracks which instruction references which BasicBlock |
Chris Lattner | 99dbdf7 | 2003-07-26 23:04:00 +0000 | [diff] [blame] | 34 | std::vector<std::pair<const BasicBlock*, |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 35 | std::pair<unsigned*,MachineInstr*> > > BBRefs; |
| 36 | // Tracks where each BasicBlock starts |
Chris Lattner | 99dbdf7 | 2003-07-26 23:04:00 +0000 | [diff] [blame] | 37 | std::map<const BasicBlock*, long> BBLocations; |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 38 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 39 | public: |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 40 | SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M); |
| 41 | ~SparcV9CodeEmitter(); |
Misha Brukman | 5bf351c | 2003-05-30 20:17:33 +0000 | [diff] [blame] | 42 | |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 43 | /// runOnMachineFunction - emits the given machine function to memory. |
| 44 | /// |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 45 | bool runOnMachineFunction(MachineFunction &F); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 46 | |
| 47 | /// emitWord - writes out the given 32-bit value to memory at the current PC. |
| 48 | /// |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 49 | void emitWord(unsigned Val); |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 50 | |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 51 | /// getBinaryCodeForInstr - This function, generated by the |
| 52 | /// CodeEmitterGenerator using TableGen, produces the binary encoding for |
| 53 | /// machine instructions. |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 54 | /// |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 55 | unsigned getBinaryCodeForInstr(MachineInstr &MI); |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 56 | |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 57 | /// emitFarCall - produces a code sequence to make a call to a destination |
| 58 | /// that does not fit in the 30 bits that a call instruction allows. |
Misha Brukman | 4510698 | 2003-08-06 16:20:22 +0000 | [diff] [blame] | 59 | /// If the function F is non-null, this also saves the return address in |
| 60 | /// the LazyResolver map of the JITResolver. |
| 61 | void emitFarCall(uint64_t Addr, Function *F = 0); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 62 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 63 | private: |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 64 | /// getMachineOpValue - |
| 65 | /// |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 66 | int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 67 | |
| 68 | /// emitBasicBlock - |
| 69 | /// |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 70 | void emitBasicBlock(MachineBasicBlock &MBB); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 71 | |
| 72 | /// getValueBit - |
| 73 | /// |
| 74 | unsigned getValueBit(int64_t Val, unsigned bit); |
| 75 | |
| 76 | /// getGlobalAddress - |
| 77 | /// |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 78 | void* getGlobalAddress(GlobalValue *V, MachineInstr &MI, |
| 79 | bool isPCRelative); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 80 | /// emitFarCall - |
| 81 | /// |
Misha Brukman | b402819 | 2003-07-14 23:26:03 +0000 | [diff] [blame] | 82 | unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI); |
Misha Brukman | 384cb5d | 2003-07-15 19:09:43 +0000 | [diff] [blame] | 83 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame^] | 86 | } // End llvm namespace |
| 87 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 88 | #endif |