2003-05-30 20:17:33 +00:00
|
|
|
//===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2003-10-21 15:17:13 +00: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-15 20:23:13 +00: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-30 20:17:33 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-05-27 21:45:05 +00:00
|
|
|
|
|
|
|
#ifndef SPARCV9CODEEMITTER_H
|
|
|
|
#define SPARCV9CODEEMITTER_H
|
|
|
|
|
2003-05-27 22:41:44 +00:00
|
|
|
#include "llvm/BasicBlock.h"
|
2003-05-27 21:45:05 +00:00
|
|
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2003-05-30 20:17:33 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
class GlobalValue;
|
|
|
|
class MachineInstr;
|
|
|
|
class MachineOperand;
|
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
class SparcV9CodeEmitter : public MachineFunctionPass {
|
2003-06-04 20:01:13 +00:00
|
|
|
TargetMachine &TM;
|
|
|
|
MachineCodeEmitter &MCE;
|
2003-07-26 23:04:00 +00:00
|
|
|
const BasicBlock *currBB;
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
// Tracks which instruction references which BasicBlock
|
2003-07-26 23:04:00 +00:00
|
|
|
std::vector<std::pair<const BasicBlock*,
|
2003-06-02 04:12:39 +00:00
|
|
|
std::pair<unsigned*,MachineInstr*> > > BBRefs;
|
|
|
|
// Tracks where each BasicBlock starts
|
2003-07-26 23:04:00 +00:00
|
|
|
std::map<const BasicBlock*, long> BBLocations;
|
2003-06-04 20:01:13 +00:00
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
public:
|
2003-06-04 20:01:13 +00:00
|
|
|
SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
|
2004-11-22 20:25:10 +00:00
|
|
|
~SparcV9CodeEmitter() {}
|
2003-05-30 20:17:33 +00:00
|
|
|
|
2004-04-15 20:23:13 +00:00
|
|
|
const char *getPassName() const { return "SparcV9 Machine Code Emitter"; }
|
|
|
|
|
2003-07-29 20:52:56 +00:00
|
|
|
/// runOnMachineFunction - emits the given machine function to memory.
|
|
|
|
///
|
2003-05-27 21:45:05 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
2003-07-29 20:52:56 +00:00
|
|
|
|
|
|
|
/// emitWord - writes out the given 32-bit value to memory at the current PC.
|
|
|
|
///
|
2003-06-04 20:01:13 +00:00
|
|
|
void emitWord(unsigned Val);
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-07-29 20:52:56 +00:00
|
|
|
/// getBinaryCodeForInstr - This function, generated by the
|
|
|
|
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
|
|
|
|
/// machine instructions.
|
2003-05-27 21:45:05 +00:00
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
unsigned getBinaryCodeForInstr(MachineInstr &MI);
|
2003-05-27 21:45:05 +00:00
|
|
|
|
|
|
|
private:
|
2003-07-29 20:52:56 +00:00
|
|
|
/// getMachineOpValue -
|
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
|
2003-07-29 20:52:56 +00:00
|
|
|
|
|
|
|
/// emitBasicBlock -
|
|
|
|
///
|
2003-05-27 21:45:05 +00:00
|
|
|
void emitBasicBlock(MachineBasicBlock &MBB);
|
2003-07-29 20:52:56 +00:00
|
|
|
|
|
|
|
/// getValueBit -
|
|
|
|
///
|
|
|
|
unsigned getValueBit(int64_t Val, unsigned bit);
|
|
|
|
|
|
|
|
/// getGlobalAddress -
|
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
|
|
|
|
bool isPCRelative);
|
2003-07-29 20:52:56 +00:00
|
|
|
/// emitFarCall -
|
|
|
|
///
|
2003-07-14 23:26:03 +00:00
|
|
|
unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
|
2003-07-15 19:09:43 +00:00
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
#endif
|