-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInline.h
More file actions
39 lines (31 loc) · 1.21 KB
/
Copy pathInline.h
File metadata and controls
39 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// function inlining: replace a call to a small, non-recursive function with a
// clone of the callee's body, splicing the callee's control and memory edges
// into the caller and merging its returns at the call's continuation
//
// references:
// - C. Click and M. Paleczny, "A Simple Graph-Based Intermediate
// Representation", ACM SIGPLAN Workshop on IRs, 1995
// - S. Muchnick, "Advanced Compiler Design and Implementation", 1997, ch. 15
#ifndef RAT_PASS_OPT_INLINE_H
#define RAT_PASS_OPT_INLINE_H
#include "Core.h"
#include "Pass/Pass.h"
namespace rat {
struct Function;
struct Module;
struct Node;
struct CallNode;
struct InlinePass : Pass {
static constexpr U32 kInlineNodeBudget = 64; // max callee size to inline
static constexpr U32 kMaxInlinesPerFunction = 256; // per-caller fuel
const C8* name() const override;
B32 run(Module& module) override;
private:
B32 isStartProj(const Function& callee, Node* n);
Node* incomingForStartProj(CallNode* call, U32 startProjIdx);
B32 shouldInline(const Function& caller, CallNode* call, Function* callee);
B32 inlineCallSite(Function& caller, CallNode* call, Function& callee);
U32 inlineInto(Function& caller, Module& m);
};
} // namespace rat
#endif