File tree Expand file tree Collapse file tree 4 files changed +50
-8
lines changed
src/dev/engine/internal/llvm Expand file tree Collapse file tree 4 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ target_sources(scratchcpp
99 llvmcoroutine.h
1010 llvmvariableptr.h
1111 llvmprocedure.h
12+ llvmtypes.cpp
13+ llvmtypes.h
1214 llvmexecutablecode.cpp
1315 llvmexecutablecode.h
1416 llvmexecutioncontext.cpp
Original file line number Diff line number Diff line change 1313#include " llvmexecutablecode.h"
1414#include " llvmifstatement.h"
1515#include " llvmloop.h"
16+ #include " llvmtypes.h"
1617
1718using namespace libscratchcpp ;
1819
@@ -976,14 +977,7 @@ void LLVMCodeBuilder::yield()
976977
977978void LLVMCodeBuilder::initTypes ()
978979{
979- // Create the ValueData struct
980- llvm::Type *unionType = m_builder.getInt64Ty (); // 64 bits is the largest size
981-
982- llvm::Type *valueType = llvm::Type::getInt32Ty (m_ctx); // Assuming ValueType is a 32-bit enum
983- llvm::Type *sizeType = llvm::Type::getInt64Ty (m_ctx); // size_t
984-
985- m_valueDataType = llvm::StructType::create (m_ctx, " ValueData" );
986- m_valueDataType->setBody ({ unionType, valueType, sizeType });
980+ m_valueDataType = LLVMTypes::createValueDataType (&m_builder);
987981}
988982
989983void LLVMCodeBuilder::createVariableMap ()
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+
3+ #include < llvm/IR/IRBuilder.h>
4+
5+ #include " llvmtypes.h"
6+
7+ using namespace libscratchcpp ;
8+
9+ llvm::StructType *LLVMTypes::createValueDataType (llvm::IRBuilder<> *builder)
10+ {
11+ llvm::LLVMContext &ctx = builder->getContext ();
12+
13+ // Create the ValueData struct
14+ llvm::Type *unionType = builder->getInt64Ty (); // 64 bits is the largest size
15+
16+ llvm::Type *valueType = llvm::Type::getInt32Ty (ctx); // Assuming ValueType is a 32-bit enum
17+ llvm::Type *sizeType = llvm::Type::getInt64Ty (ctx); // size_t
18+
19+ llvm::StructType *ret = llvm::StructType::create (ctx, " ValueData" );
20+ ret->setBody ({ unionType, valueType, sizeType });
21+
22+ return ret;
23+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+
3+ #pragma once
4+
5+ #include < llvm/IR/IRBuilder.h>
6+
7+ namespace llvm
8+ {
9+
10+ class StructValue ;
11+
12+ }
13+
14+ namespace libscratchcpp
15+ {
16+
17+ class LLVMTypes
18+ {
19+ public:
20+ static llvm::StructType *createValueDataType (llvm::IRBuilder<> *builder);
21+ };
22+
23+ } // namespace libscratchcpp
You can’t perform that action at this time.
0 commit comments