mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-27 00:53:23 +01:00
Moved constant array creation helper to llvmhelpers.h.
This commit is contained in:
@@ -220,4 +220,17 @@ void printLabelName(std::ostream& target, const char* func_mangle, const char* l
|
||||
|
||||
void AppendFunctionToLLVMGlobalCtorsDtors(llvm::Function* func, const uint32_t priority, const bool isCtor);
|
||||
|
||||
template <typename T>
|
||||
LLConstant* toConstantArray(LLType* ct, LLArrayType* at, T* str, size_t len, bool nullterm = true)
|
||||
{
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.reserve(len+1);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
vals.push_back(LLConstantInt::get(ct, str[i], false));
|
||||
}
|
||||
if (nullterm)
|
||||
vals.push_back(LLConstantInt::get(ct, 0, false));
|
||||
return LLConstantArray::get(at, vals);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
15
gen/toir.cpp
15
gen/toir.cpp
@@ -423,21 +423,6 @@ LLConstant* ComplexExp::toConstElem(IRState* p)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T>
|
||||
static inline LLConstant* toConstantArray(LLType* ct, LLArrayType* at, T* str, size_t len, bool nullterm = true)
|
||||
{
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.reserve(len+1);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
vals.push_back(LLConstantInt::get(ct, str[i], false));
|
||||
}
|
||||
if (nullterm)
|
||||
vals.push_back(LLConstantInt::get(ct, 0, false));
|
||||
return LLConstantArray::get(at, vals);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DValue* StringExp::toElem(IRState* p)
|
||||
{
|
||||
Logger::print("StringExp::toElem: %s @ %s\n", toChars(), type->toChars());
|
||||
|
||||
Reference in New Issue
Block a user