llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
runtime_printer.h
1 // This file if part of the llir-opt project.
2 // Licensing information can be found in the LICENSE file.
3 // (C) 2018 Nandor Licker. All rights reserved.
4 
5 #pragma once
6 
7 #include <llvm/Pass.h>
8 #include <llvm/MC/MCObjectFileInfo.h>
9 #include <llvm/MC/MCStreamer.h>
10 #include <llvm/Target/TargetMachine.h>
11 
12 class Prog;
13 class Data;
14 
15 
16 
20 class RuntimePrinter : public llvm::ModulePass {
21 public:
24  char &ID,
25  const Prog &Prog,
26  const llvm::TargetMachine &tm,
27  llvm::MCContext &ctx,
28  llvm::MCStreamer &os,
29  const llvm::MCObjectFileInfo &objInfo,
30  bool shared
31  );
32 
33 private:
35  bool runOnModule(llvm::Module &M) override;
37  void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
38 
39 protected:
41  virtual void EmitCamlCallGc(llvm::Function &F) = 0;
43  virtual void EmitCamlCCall(llvm::Function &F) = 0;
44 
45 protected:
47  const Prog &prog_;
49  const llvm::TargetMachine &tm_;
51  llvm::MCContext &ctx_;
53  llvm::MCStreamer &os_;
55  const llvm::MCObjectFileInfo &objInfo_;
57  const llvm::DataLayout layout_;
59  bool shared_;
60 };
RuntimePrinter::ctx_
llvm::MCContext & ctx_
LLVM context.
Definition: runtime_printer.h:51
RuntimePrinter::shared_
bool shared_
Flag to indicate whether a shared library or a static library is built.
Definition: runtime_printer.h:59
RuntimePrinter::RuntimePrinter
RuntimePrinter(char &ID, const Prog &Prog, const llvm::TargetMachine &tm, llvm::MCContext &ctx, llvm::MCStreamer &os, const llvm::MCObjectFileInfo &objInfo, bool shared)
Initialises the pass which prints data sections.
Definition: runtime_printer.cpp:25
Data
Definition: data.h:47
ID
Definition: id.h:19
RuntimePrinter::layout_
const llvm::DataLayout layout_
Data layout.
Definition: runtime_printer.h:57
RuntimePrinter::tm_
const llvm::TargetMachine & tm_
Reference to the target machine.
Definition: runtime_printer.h:49
RuntimePrinter::prog_
const Prog & prog_
Program to print.
Definition: runtime_printer.h:47
RuntimePrinter::EmitCamlCallGc
virtual void EmitCamlCallGc(llvm::Function &F)=0
Emits caml_call_gc.
Prog
Definition: prog.h:33
RuntimePrinter::objInfo_
const llvm::MCObjectFileInfo & objInfo_
Object-file specific information.
Definition: runtime_printer.h:55
RuntimePrinter::EmitCamlCCall
virtual void EmitCamlCCall(llvm::Function &F)=0
Emits caml_c_call.
RuntimePrinter
Definition: runtime_printer.h:20
RuntimePrinter::os_
llvm::MCStreamer & os_
Streamer to emit output to.
Definition: runtime_printer.h:53