fix some GCC 4 warnings
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9CodeEmitter.h
1 //===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===//
2 //
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 // Target-specific portions of the machine code emitter for the SparcV9.
11 // This class interfaces with the JIT's Emitter in order to turn MachineInstrs
12 // into words of binary machine code. Its code is partially generated by
13 // TableGen's CodeEmitterGenerator.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef SPARCV9CODEEMITTER_H
18 #define SPARCV9CODEEMITTER_H
19
20 #include "llvm/BasicBlock.h"
21 #include "llvm/CodeGen/MachineCodeEmitter.h"
22 #include "llvm/CodeGen/MachineFunctionPass.h"
23 #include "llvm/Target/TargetMachine.h"
24
25 namespace llvm {
26
27 class GlobalValue;
28 class MachineInstr;
29 class MachineOperand;
30
31 class SparcV9CodeEmitter : public MachineFunctionPass {
32   TargetMachine &TM;
33   MachineCodeEmitter &MCE;
34   const BasicBlock *currBB;
35
36   // Tracks which instruction references which BasicBlock
37   std::vector<std::pair<const BasicBlock*,
38                         std::pair<unsigned*,MachineInstr*> > > BBRefs;
39   // Tracks where each BasicBlock starts
40   std::map<const BasicBlock*, long> BBLocations;
41
42 public:
43   SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
44   ~SparcV9CodeEmitter() {}
45
46   const char *getPassName() const { return "SparcV9 Machine Code Emitter"; }
47
48   /// runOnMachineFunction - emits the given machine function to memory.
49   ///
50   bool runOnMachineFunction(MachineFunction &F);
51
52   /// emitWord - writes out the given 32-bit value to memory at the current PC.
53   ///
54   void emitWord(unsigned Val);
55
56   /// getBinaryCodeForInstr - This function, generated by the
57   /// CodeEmitterGenerator using TableGen, produces the binary encoding for
58   /// machine instructions.
59   ///
60   unsigned getBinaryCodeForInstr(MachineInstr &MI);
61
62 private:
63   /// getMachineOpValue -
64   ///
65   int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
66
67   /// emitBasicBlock -
68   ///
69   void emitBasicBlock(MachineBasicBlock &MBB);
70
71   /// getValueBit -
72   ///
73   unsigned getValueBit(int64_t Val, unsigned bit);
74
75   /// getGlobalAddress -
76   ///
77   void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
78                          bool isPCRelative);
79   /// emitFarCall -
80   ///
81   unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
82
83 };
84
85 } // End llvm namespace
86
87 #endif