Commit cc1db1c2 authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

correct a failed cherry-pick

parent 11871053
......@@ -274,6 +274,35 @@ namespace cecko {
return vars_.try_emplace(name, type_pack, var, false);
}
CKStructTypeObs CKLocalTable::declare_struct_type(const CIName& n, CKIRContextRef Context)
{
auto p = find_struct_type(n);
if (p)
return p;
return declare_struct_type_here(n, Context);
}
CKStructTypeObs CKLocalTable::find_struct_type(const CIName& n)
{
auto p = find_struct_type_here(n);
if (p)
return p;
return parent_scope_->find_struct_type(n);
}
CKEnumTypeObs CKLocalTable::declare_enum_type(const CIName& n, CKTypeObs base_type)
{
auto p = find_enum_type(n);
if (p)
return p;
return declare_enum_type_here(n, base_type);
}
CKEnumTypeObs CKLocalTable::find_enum_type(const CIName& n)
{
auto p = find_enum_type_here(n);
if (p)
return p;
return parent_scope_->find_enum_type(n);
}
CKTypedefConstObs CKLocalTable::find_typedef(const CIName& n) const
{
auto p = find_typedef_here(n);
......@@ -418,7 +447,9 @@ namespace cecko {
globtable_(tab->globtable()),
loctable_(nullptr),
module_(tab->module()),
alloca_builder_(tab->module()->getContext()),
builder_(tab->module()->getContext()),
start_bb_(nullptr),
data_layout_(tab->data_layout())
{
}
......@@ -427,9 +458,11 @@ namespace cecko {
{
assert(!loctable_);
// FUNCTION PROLOG
auto BB = CKCreateBasicBlock("prolog", f->get_function_ir());
builder_.SetInsertPoint(BB);
loctable_ = f->define(globtable_, builder_, std::move(pack));
auto BB0 = CKCreateBasicBlock("prolog", f->get_function_ir());
alloca_builder_.SetInsertPoint(BB0);
loctable_ = f->define(globtable_, alloca_builder_, std::move(pack));
start_bb_ = CKCreateBasicBlock("start", f->get_function_ir());
builder_.SetInsertPoint(start_bb_);
}
void CKContext::exit_function()
......@@ -437,6 +470,9 @@ namespace cecko {
assert(loctable_);
loctable_ = nullptr;
builder_.ClearInsertionPoint();
alloca_builder_.CreateBr(start_bb_);
start_bb_ = nullptr;
alloca_builder_.ClearInsertionPoint();
}
void CKContext::enter_block()
......
......@@ -755,6 +755,8 @@ namespace cecko {
class CKAbstractScope : CIImmovable {
public:
virtual ~CKAbstractScope() {}
virtual CKStructTypeObs find_struct_type(const CIName& n) = 0;
virtual CKEnumTypeObs find_enum_type(const CIName& n) = 0;
virtual CKTypedefConstObs find_typedef(const CIName& n) const = 0;
virtual CKNamedObs find(const CIName& n) = 0;
virtual CKLocalTableObs get_local();
......@@ -796,16 +798,16 @@ namespace cecko {
/// @cond INTERNAL
class CKUniversalTable : public CKAbstractScope {
public:
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context)
CKStructTypeObs declare_struct_type_here(const CIName& n, CKIRContextRef Context)
{
return strts_.try_emplace(n, Context, n);
}
CKStructTypeObs find_struct_type(const CIName& n) { return strts_.find(n); }
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type)
CKStructTypeObs find_struct_type_here(const CIName& n) { return strts_.find(n); }
CKEnumTypeObs declare_enum_type_here(const CIName& n, CKTypeObs base_type)
{
return enmts_.try_emplace(n, base_type);
}
CKEnumTypeObs find_enum_type(const CIName& n) { return enmts_.find(n); }
CKEnumTypeObs find_enum_type_here(const CIName& n) { return enmts_.find(n); }
CKTypedefConstObs declare_typedef(const CIName& name, const CKTypeRefPack& type_pack);
CKConstantConstObs declare_constant(const std::string& name, CKTypeObs type, CKIRConstantIntObs value);
CKTypedefConstObs find_typedef_here(const CIName& n) const;
......@@ -831,6 +833,16 @@ namespace cecko {
{}
CKGlobalVarObs varDefine(CKIRModuleObs M, const std::string& name, const CKTypeRefPack& type_pack);
CKGlobalVarObs declare_extern_variable(CKIRModuleObs M, const std::string& name, const CKTypeRefPack& type_pack);
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context)
{
return declare_struct_type_here(n, Context);
}
virtual CKStructTypeObs find_struct_type(const CIName& n) override { return find_struct_type_here(n); }
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type)
{
return declare_enum_type_here(n, base_type);
}
virtual CKEnumTypeObs find_enum_type(const CIName& n) override { return find_enum_type_here(n); }
CKFunctionObs declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type);
CKFunctionObs declare_function(const CIName& n, CKIRModuleObs M, CKFunctionTypeObs type, const std::string& irname);
CKFunctionObs find_function(const CIName& n);
......@@ -870,6 +882,11 @@ namespace cecko {
: parent_scope_(parent)
{}
CKStructTypeObs declare_struct_type(const CIName& n, CKIRContextRef Context);
virtual CKStructTypeObs find_struct_type(const CIName& n) override;
CKEnumTypeObs declare_enum_type(const CIName& n, CKTypeObs base_type);
virtual CKEnumTypeObs find_enum_type(const CIName& n) override;
void varsFromArgs(CKIRBuilderRef builder, CKFunctionObs f, const CKFunctionFormalPackArray& formal_packs);
CKLocalVarObs varDefine(CKIRBuilderRef builder, const std::string& name, const CKTypeRefPack& type_pack);
......@@ -1107,7 +1124,9 @@ namespace cecko {
CKIRModuleObs module_;
CKLocalTableObs loctable_;
CKIRBuilder alloca_builder_;
CKIRBuilder builder_;
CKIRBasicBlockObs start_bb_;
CKIRDataLayoutObs data_layout_;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment