2016-09-26 07:00:19 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class SSAInt;
|
|
|
|
|
|
|
|
class SSAScope
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SSAScope(llvm::LLVMContext *context, llvm::Module *module, llvm::IRBuilder<> *builder);
|
|
|
|
~SSAScope();
|
|
|
|
static llvm::LLVMContext &context();
|
|
|
|
static llvm::Module *module();
|
|
|
|
static llvm::IRBuilder<> &builder();
|
|
|
|
static llvm::Function *intrinsic(llvm::Intrinsic::ID id, llvm::ArrayRef<llvm::Type *> parameter_types = llvm::ArrayRef<llvm::Type*>());
|
|
|
|
static llvm::Value *alloca(llvm::Type *type);
|
|
|
|
static llvm::Value *alloca(llvm::Type *type, SSAInt size);
|
2016-10-08 07:29:26 +00:00
|
|
|
static llvm::MDNode *constant_scope_list();
|
2016-09-26 07:00:19 +00:00
|
|
|
static const std::string &hint();
|
|
|
|
static void set_hint(const std::string &hint);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static SSAScope *instance;
|
|
|
|
llvm::LLVMContext *_context;
|
|
|
|
llvm::Module *_module;
|
|
|
|
llvm::IRBuilder<> *_builder;
|
2016-10-08 07:29:26 +00:00
|
|
|
llvm::MDNode *_constant_scope_domain;
|
|
|
|
llvm::MDNode *_constant_scope;
|
|
|
|
llvm::MDNode *_constant_scope_list;
|
2016-09-26 07:00:19 +00:00
|
|
|
std::string _hint;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SSAScopeHint
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SSAScopeHint() : old_hint(SSAScope::hint()) { }
|
|
|
|
SSAScopeHint(const std::string &hint) : old_hint(SSAScope::hint()) { SSAScope::set_hint(hint); }
|
|
|
|
~SSAScopeHint() { SSAScope::set_hint(old_hint); }
|
|
|
|
void set(const std::string &hint) { SSAScope::set_hint(hint); }
|
|
|
|
void clear() { SSAScope::set_hint(old_hint); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string old_hint;
|
|
|
|
};
|