blob: e9ee936a48655cddfab72f06380b184aa593fbaf [file] [log] [blame]
Bruno Cardoso Lopes4cb31432009-06-03 17:47:27 +00001//===-- lib/CodeGen/ELFCodeEmitter.h ----------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef ELFCODEEMITTER_H
11#define ELFCODEEMITTER_H
12
13#include "ELFWriter.h"
14#include "llvm/CodeGen/MachineCodeEmitter.h"
15#include <vector>
16
17namespace llvm {
18
19 /// ELFCodeEmitter - This class is used by the ELFWriter to
20 /// emit the code for functions to the ELF file.
21 class ELFCodeEmitter : public MachineCodeEmitter {
22 ELFWriter &EW;
23 TargetMachine &TM;
Bruno Cardoso Lopesf5b0c5a2009-06-06 03:56:29 +000024 ELFSection *ES; // Section to write to.
Bruno Cardoso Lopes5d419102009-06-05 00:22:10 +000025 uint8_t *FnStartPtr;
Bruno Cardoso Lopes4cb31432009-06-03 17:47:27 +000026 public:
Bruno Cardoso Lopes5d419102009-06-05 00:22:10 +000027 explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM) {}
Bruno Cardoso Lopes4cb31432009-06-03 17:47:27 +000028
29 void startFunction(MachineFunction &F);
30 bool finishFunction(MachineFunction &F);
31
32 void addRelocation(const MachineRelocation &MR) {
33 assert(0 && "relo not handled yet!");
34 }
35
36 virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) {
37 }
38
39 virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const {
40 assert(0 && "CP not implementated yet!");
41 return 0;
42 }
43 virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const {
44 assert(0 && "JT not implementated yet!");
45 return 0;
46 }
47
48 virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const {
49 assert(0 && "JT not implementated yet!");
50 return 0;
51 }
52
53 virtual uintptr_t getLabelAddress(uint64_t Label) const {
54 assert(0 && "Label address not implementated yet!");
55 abort();
56 return 0;
57 }
58
59 virtual void emitLabel(uint64_t LabelID) {
60 assert(0 && "emit Label not implementated yet!");
61 abort();
62 }
63
64 virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { }
65
66 /// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
67 void startGVStub(const GlobalValue* F, unsigned StubSize,
68 unsigned Alignment = 1) {
69 assert(0 && "JIT specific function called!");
70 abort();
71 }
72 void startGVStub(const GlobalValue* F, void *Buffer, unsigned StubSize) {
73 assert(0 && "JIT specific function called!");
74 abort();
75 }
76 void *finishGVStub(const GlobalValue *F) {
77 assert(0 && "JIT specific function called!");
78 abort();
79 return 0;
80 }
81}; // end class ELFCodeEmitter
82
83} // end namespace llvm
84
85#endif
86