2003-05-31 04:17:33 +08:00
|
|
|
//===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2003-10-21 23:17:13 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2004-04-16 04:23:13 +08:00
|
|
|
// Target-specific portions of the machine code emitter for the SparcV9.
|
|
|
|
// This class interfaces with the JIT's Emitter in order to turn MachineInstrs
|
|
|
|
// into words of binary machine code. Its code is partially generated by
|
|
|
|
// TableGen's CodeEmitterGenerator.
|
2003-05-31 04:17:33 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-05-28 05:45:05 +08:00
|
|
|
|
|
|
|
#ifndef SPARCV9CODEEMITTER_H
|
|
|
|
#define SPARCV9CODEEMITTER_H
|
|
|
|
|
2003-05-28 06:41:44 +08:00
|
|
|
#include "llvm/BasicBlock.h"
|
2003-05-28 05:45:05 +08:00
|
|
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2003-05-31 04:17:33 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-05-28 05:45:05 +08:00
|
|
|
|
2003-11-12 06:41:34 +08:00
|
|
|
namespace llvm {
|
|
|
|
|
2003-06-02 12:12:39 +08:00
|
|
|
class GlobalValue;
|
|
|
|
class MachineInstr;
|
|
|
|
class MachineOperand;
|
|
|
|
|
2003-05-28 05:45:05 +08:00
|
|
|
class SparcV9CodeEmitter : public MachineFunctionPass {
|
2003-06-05 04:01:13 +08:00
|
|
|
TargetMachine &TM;
|
|
|
|
MachineCodeEmitter &MCE;
|
2003-07-27 07:04:00 +08:00
|
|
|
const BasicBlock *currBB;
|
2003-05-28 05:45:05 +08:00
|
|
|
|
2003-06-02 12:12:39 +08:00
|
|
|
// Tracks which instruction references which BasicBlock
|
2003-07-27 07:04:00 +08:00
|
|
|
std::vector<std::pair<const BasicBlock*,
|
2003-06-02 12:12:39 +08:00
|
|
|
std::pair<unsigned*,MachineInstr*> > > BBRefs;
|
|
|
|
// Tracks where each BasicBlock starts
|
2003-07-27 07:04:00 +08:00
|
|
|
std::map<const BasicBlock*, long> BBLocations;
|
2003-06-05 04:01:13 +08:00
|
|
|
|
2003-05-28 05:45:05 +08:00
|
|
|
public:
|
2003-06-05 04:01:13 +08:00
|
|
|
SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
|
2004-11-23 04:25:10 +08:00
|
|
|
~SparcV9CodeEmitter() {}
|
2003-05-31 04:17:33 +08:00
|
|
|
|
2004-04-16 04:23:13 +08:00
|
|
|
const char *getPassName() const { return "SparcV9 Machine Code Emitter"; }
|
|
|
|
|
2003-07-30 04:52:56 +08:00
|
|
|
/// runOnMachineFunction - emits the given machine function to memory.
|
|
|
|
///
|
2003-05-28 05:45:05 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
2003-07-30 04:52:56 +08:00
|
|
|
|
|
|
|
/// emitWord - writes out the given 32-bit value to memory at the current PC.
|
|
|
|
///
|
2003-06-05 04:01:13 +08:00
|
|
|
void emitWord(unsigned Val);
|
2003-05-28 05:45:05 +08:00
|
|
|
|
2003-07-30 04:52:56 +08:00
|
|
|
/// getBinaryCodeForInstr - This function, generated by the
|
|
|
|
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
|
|
|
|
/// machine instructions.
|
2003-05-28 05:45:05 +08:00
|
|
|
///
|
2003-06-02 12:12:39 +08:00
|
|
|
unsigned getBinaryCodeForInstr(MachineInstr &MI);
|
2003-05-28 05:45:05 +08:00
|
|
|
|
|
|
|
private:
|
2003-07-30 04:52:56 +08:00
|
|
|
/// getMachineOpValue -
|
|
|
|
///
|
2003-06-02 12:12:39 +08:00
|
|
|
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
|
2003-07-30 04:52:56 +08:00
|
|
|
|
|
|
|
/// emitBasicBlock -
|
|
|
|
///
|
2003-05-28 05:45:05 +08:00
|
|
|
void emitBasicBlock(MachineBasicBlock &MBB);
|
2003-07-30 04:52:56 +08:00
|
|
|
|
|
|
|
/// getValueBit -
|
|
|
|
///
|
|
|
|
unsigned getValueBit(int64_t Val, unsigned bit);
|
|
|
|
|
|
|
|
/// getGlobalAddress -
|
|
|
|
///
|
2003-06-02 12:12:39 +08:00
|
|
|
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
|
|
|
|
bool isPCRelative);
|
2003-07-30 04:52:56 +08:00
|
|
|
/// emitFarCall -
|
|
|
|
///
|
2003-07-15 07:26:03 +08:00
|
|
|
unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
|
2003-07-16 03:09:43 +08:00
|
|
|
|
2003-05-28 05:45:05 +08:00
|
|
|
};
|
|
|
|
|
2003-11-12 06:41:34 +08:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2003-05-28 05:45:05 +08:00
|
|
|
#endif
|