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 | |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 22 | class GlobalValue; |
| 23 | class MachineInstr; |
| 24 | class MachineOperand; |
| 25 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 26 | class SparcV9CodeEmitter : public MachineFunctionPass { |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 27 | TargetMachine &TM; |
| 28 | MachineCodeEmitter &MCE; |
Chris Lattner | 99dbdf7 | 2003-07-26 23:04:00 +0000 | [diff] [blame] | 29 | const BasicBlock *currBB; |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 30 | |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 31 | // Tracks which instruction references which BasicBlock |
Chris Lattner | 99dbdf7 | 2003-07-26 23:04:00 +0000 | [diff] [blame] | 32 | std::vector<std::pair<const BasicBlock*, |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 33 | std::pair<unsigned*,MachineInstr*> > > BBRefs; |
| 34 | // Tracks where each BasicBlock starts |
Chris Lattner | 99dbdf7 | 2003-07-26 23:04:00 +0000 | [diff] [blame] | 35 | std::map<const BasicBlock*, long> BBLocations; |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 36 | |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 37 | // Tracks locations of Constants which are laid out in memory (e.g. FP) |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 38 | // But we also need to map Constants to ConstantPool indices |
| 39 | std::map<const Constant*, unsigned> ConstantMap; |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 40 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 41 | public: |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 42 | SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M); |
| 43 | ~SparcV9CodeEmitter(); |
Misha Brukman | 5bf351c | 2003-05-30 20:17:33 +0000 | [diff] [blame] | 44 | |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 45 | /// runOnMachineFunction - emits the given machine function to memory. |
| 46 | /// |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 47 | bool runOnMachineFunction(MachineFunction &F); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 48 | |
| 49 | /// emitWord - writes out the given 32-bit value to memory at the current PC. |
| 50 | /// |
Misha Brukman | efafdf8 | 2003-06-04 20:01:13 +0000 | [diff] [blame] | 51 | void emitWord(unsigned Val); |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 52 | |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 53 | /// getBinaryCodeForInstr - This function, generated by the |
| 54 | /// CodeEmitterGenerator using TableGen, produces the binary encoding for |
| 55 | /// machine instructions. |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 56 | /// |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 57 | unsigned getBinaryCodeForInstr(MachineInstr &MI); |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 58 | |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 59 | /// emitFarCall - produces a code sequence to make a call to a destination |
| 60 | /// 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] | 61 | /// If the function F is non-null, this also saves the return address in |
| 62 | /// the LazyResolver map of the JITResolver. |
| 63 | void emitFarCall(uint64_t Addr, Function *F = 0); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 64 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 65 | private: |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 66 | /// getMachineOpValue - |
| 67 | /// |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 68 | int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 69 | |
| 70 | /// emitBasicBlock - |
| 71 | /// |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 72 | void emitBasicBlock(MachineBasicBlock &MBB); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 73 | |
| 74 | /// getValueBit - |
| 75 | /// |
| 76 | unsigned getValueBit(int64_t Val, unsigned bit); |
| 77 | |
| 78 | /// getGlobalAddress - |
| 79 | /// |
Misha Brukman | ce62d36 | 2003-06-02 04:12:39 +0000 | [diff] [blame] | 80 | void* getGlobalAddress(GlobalValue *V, MachineInstr &MI, |
| 81 | bool isPCRelative); |
Misha Brukman | fb8f64a | 2003-07-29 20:52:56 +0000 | [diff] [blame] | 82 | /// emitFarCall - |
| 83 | /// |
Misha Brukman | b402819 | 2003-07-14 23:26:03 +0000 | [diff] [blame] | 84 | unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI); |
Misha Brukman | 384cb5d | 2003-07-15 19:09:43 +0000 | [diff] [blame] | 85 | |
Misha Brukman | e195b7c | 2003-05-27 21:45:05 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | #endif |