blob: d9a03e5b2314f6d62965c68cddcf54918095c162 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===//
//
//
//===----------------------------------------------------------------------===//
#ifndef SPARCV9CODEEMITTER_H
#define SPARCV9CODEEMITTER_H
#include "llvm/BasicBlock.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Target/TargetMachine.h"
class GlobalValue;
class MachineInstr;
class MachineOperand;
class SparcV9CodeEmitter : public MachineFunctionPass {
TargetMachine &TM;
MachineCodeEmitter &MCE;
BasicBlock *currBB;
// Tracks which instruction references which BasicBlock
std::vector<std::pair<BasicBlock*,
std::pair<unsigned*,MachineInstr*> > > BBRefs;
// Tracks where each BasicBlock starts
std::map<BasicBlock*, long> BBLocations;
// Tracks locations of Constants which are laid out in memory (e.g. FP)
// But we also need to map Constants to ConstantPool indices
std::map<const Constant*, unsigned> ConstantMap;
public:
SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
~SparcV9CodeEmitter();
bool runOnMachineFunction(MachineFunction &F);
void emitWord(unsigned Val);
/// Function generated by the CodeEmitterGenerator using TableGen
///
unsigned getBinaryCodeForInstr(MachineInstr &MI);
private:
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
unsigned getValueBit(int64_t Val, unsigned bit);
void emitBasicBlock(MachineBasicBlock &MBB);
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
bool isPCRelative);
bool isFPInstr(MachineInstr &MI);
unsigned getRealRegNum(unsigned fakeReg, unsigned regClass,
MachineInstr &MI);
};
#endif
|