llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
isel_mapping.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 <unordered_map>
8 
9 #include <llvm/CodeGen/MachineFunction.h>
10 #include <llvm/MC/MCSymbol.h>
11 
12 class Inst;
13 class Block;
14 class Func;
15 class CamlFrame;
16 
17 
18 
22 class ISelMapping {
23 public:
25  llvm::MachineFunction *operator[] (const Func *func) const;
27  llvm::MCSymbol *operator[] (const Inst *inst) const;
29  llvm::MachineBasicBlock *operator[] (const Block *block) const;
31  const CamlFrame *operator[] (llvm::MCSymbol *symbol) const;
32 
33 protected:
35  std::unordered_map<const Func *, llvm::MachineFunction *> funcs_;
37  std::unordered_map<const Block *, llvm::MachineBasicBlock *> mbbs_;
39  std::unordered_map<const Block *, llvm::BasicBlock *> bbs_;
41  std::unordered_map<const Inst *, llvm::MCSymbol *> labels_;
43  std::unordered_map<llvm::MCSymbol *, const CamlFrame *> frames_;
44 };
Inst
Definition: inst.h:53
Func
Definition: func.h:30
ISelMapping::labels_
std::unordered_map< const Inst *, llvm::MCSymbol * > labels_
Labels of annotated instructions.
Definition: isel_mapping.h:41
ISelMapping
Definition: isel_mapping.h:22
ISelMapping::mbbs_
std::unordered_map< const Block *, llvm::MachineBasicBlock * > mbbs_
Mapping from blocks to machine blocks.
Definition: isel_mapping.h:37
CamlFrame
Definition: annot.h:201
ISelMapping::bbs_
std::unordered_map< const Block *, llvm::BasicBlock * > bbs_
Mapping from blocks to basic blocks.
Definition: isel_mapping.h:39
ISelMapping::frames_
std::unordered_map< llvm::MCSymbol *, const CamlFrame * > frames_
Mapping from labels to instructions.
Definition: isel_mapping.h:43
Block
Definition: block.h:29
ISelMapping::operator[]
llvm::MachineFunction * operator[](const Func *func) const
Finds the MachineFunction attached to a function.
Definition: isel_mapping.cpp:10
ISelMapping::funcs_
std::unordered_map< const Func *, llvm::MachineFunction * > funcs_
Mapping from functions to MachineFunctions.
Definition: isel_mapping.h:35