xo-jit: progress towards explicit stack frames [wip, incomplete]
This commit is contained in:
parent
be3e62f75a
commit
71df4f824d
4 changed files with 118 additions and 8 deletions
|
|
@ -152,6 +152,13 @@ namespace xo {
|
|||
std::vector<ref::brw<Lambda>> find_lambdas(ref::brw<Expression> expr) const;
|
||||
|
||||
public:
|
||||
/** codegen helper for a user-defined function.
|
||||
* create stack slot on behalf of formal parameters.
|
||||
* linked to (dynamic) callers for stack unwinding
|
||||
**/
|
||||
llvm::AllocaInst * create_entry_frame_alloca(llvm::Function * llvm_fn,
|
||||
llvm::StructType * frame_llvm_type);
|
||||
|
||||
/** codegen helper for a user-defined function (codegen_lambda()):
|
||||
* create stack slot on behalf of some formal parameter to a function,
|
||||
* so we can avoid SSA restriction on function body
|
||||
|
|
|
|||
|
|
@ -22,16 +22,41 @@ namespace xo {
|
|||
**/
|
||||
class activation_record {
|
||||
public:
|
||||
activation_record() = default;
|
||||
activation_record(llvm::Function * llvm_fn,
|
||||
llvm::AllocaInst * frame) : frame_{frame} {
|
||||
int i_arg = 0;
|
||||
for (auto & arg : llvm_fn->args()) {
|
||||
std::string arg_name = std::string(arg.getName());
|
||||
|
||||
name2ix_map_[arg_name] = 2 + i_arg;
|
||||
}
|
||||
}
|
||||
|
||||
std::int32_t lookup_var(const std::string & var_name) const;
|
||||
|
||||
#ifdef OBSOLETE
|
||||
llvm::AllocaInst * lookup_var(const std::string & var_name) const;
|
||||
|
||||
llvm::AllocaInst * alloc_var(const std::string & var_name,
|
||||
llvm::AllocaInst * alloca);
|
||||
#endif
|
||||
|
||||
private:
|
||||
/** stack frame for a user-defined function (lambda) **/
|
||||
llvm::AllocaInst * frame_ = nullptr;
|
||||
|
||||
/** for each formal parameter,
|
||||
* reports its position in stack frame.
|
||||
* This is the position to use with getelementptr,
|
||||
* i.e. +2 to skip first two slots, that are reserved
|
||||
* for nextframe pointer (slot 0) + unwind pointer (slot 1)
|
||||
**/
|
||||
std::map<std::string, std::int32_t> name2ix_map_;
|
||||
|
||||
#ifdef OBSOLETE
|
||||
/** maps named slots in a stack frame to logical addresses **/
|
||||
std::map<std::string, llvm::AllocaInst*> frame_; /* <-> kaleidoscope NamedValues */
|
||||
#endif
|
||||
}; /*activation_record*/
|
||||
|
||||
} /*namespace jit*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue