File tree 4 files changed +50
-8
lines changed
src/dev/engine/internal/llvm 4 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ target_sources(scratchcpp
9
9
llvmcoroutine.h
10
10
llvmvariableptr.h
11
11
llvmprocedure.h
12
+ llvmtypes.cpp
13
+ llvmtypes.h
12
14
llvmexecutablecode.cpp
13
15
llvmexecutablecode.h
14
16
llvmexecutioncontext.cpp
Original file line number Diff line number Diff line change 13
13
#include " llvmexecutablecode.h"
14
14
#include " llvmifstatement.h"
15
15
#include " llvmloop.h"
16
+ #include " llvmtypes.h"
16
17
17
18
using namespace libscratchcpp ;
18
19
@@ -976,14 +977,7 @@ void LLVMCodeBuilder::yield()
976
977
977
978
void LLVMCodeBuilder::initTypes ()
978
979
{
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);
987
981
}
988
982
989
983
void 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