Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ src/Compiler-CodeGenerator-LLVM.cpp
*.ll
local
LLVM.bs
.vscode
4 changes: 0 additions & 4 deletions example/hash_ref.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
$generator->debug_run($ast);

__DATA__
<<<<<<< HEAD
my $a = { a => 1, b => { d => 2 }, c => 2 };
=======
my $a = { a => 1, b => { d => 8 }, c => 2 };
>>>>>>> origin/dev
say $a;
say %$a;

Expand Down
26 changes: 8 additions & 18 deletions include/codegen.hpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
#define LLVM_ATTRIBUTE_READONLY

#ifdef LLVM_VERSION_3_2

#include "llvm/IRBuilder.h"
#include "llvm/Module.h"
#include "llvm/LLVMContext.h"
#include "llvm/ValueSymbolTable.h"

#else

#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/IR/DerivedTypes.h"

#endif

#include "llvm/PassManager.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/AssemblyAnnotationWriter.h"
#include "llvm/Linker/Linker.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include <dirent.h>

Expand Down Expand Up @@ -168,7 +158,7 @@ class FunctionManager {
class LLVM {
public:
llvm::LLVMContext ctx;
llvm::Module *module;
std::unique_ptr<llvm::Module> module;
Enum::Runtime::Type cur_type;
llvm::Type *int_type;
llvm::Type *int_ptr_type;
Expand Down Expand Up @@ -269,7 +259,7 @@ class LLVM {
void storeArgument(llvm::IRBuilder<> *builder, Token *tk, llvm::Value *args, llvm::Value *idx, llvm::Value *value);
void setIteratorValue(llvm::IRBuilder<> *builder, Node *node);
void traverse(llvm::IRBuilder<> *builder, AST *ast);
bool linkModule(llvm::Module *dest, std::string filename);
bool linkModule(llvm::Module &dest, std::string filename);
void generateCode(llvm::IRBuilder<> *builder, Node *node);
llvm::BasicBlock *generateBlockCode(llvm::IRBuilder<> *builder, llvm::BasicBlock *block, llvm::BasicBlock *merge_block, Node *node);
void generateIfStmtCode(llvm::IRBuilder<> *builder, IfStmtNode *node);
Expand Down
39 changes: 27 additions & 12 deletions include/gen_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ typedef enum {
Glob,
BitNot,
BitOr,
Or,
AlphabetOr,
BitAnd,
And,
AlphabetAnd,
BitXOr,
XOr,
AlphabetXOr,
StringMul,
AddEqual,
SubEqual,
MulEqual,
DivEqual,
ModEqual,
StringAddEqual,
LeftShiftEqual,
RightShiftEqual,
StringMulEqual,
GreaterEqual,
LessEqual,
EqualEqual,
Expand All @@ -36,7 +40,6 @@ typedef enum {
RegOK,
RegNot,
NotEqual,
ArraySize,
StringLess,
StringLessEqual,
StringGreater,
Expand All @@ -51,6 +54,8 @@ typedef enum {
DefaultEqual,
LeftShift,
RightShift,
And,
Or,
AndBitEqual,
OrBitEqual,
NotBitEqual,
Expand All @@ -63,9 +68,10 @@ typedef enum {
FunctionDecl,
Method,
Assign,
ArraySize,
Is,
IsNot,
Not,
AlphabetNot,
BuiltinFunc,
RequireDecl,
Import,
Expand Down Expand Up @@ -112,6 +118,7 @@ typedef enum {
ArrayDereference,
HashDereference,
ScalarDereference,
CodeDereference,
ShortScalarDereference,
ShortArrayDereference,
ShortHashDereference,
Expand Down Expand Up @@ -174,6 +181,7 @@ typedef enum {
HereDocumentTag,
HereDocumentRawTag,
HereDocumentExecTag,
HereDocumentBareTag,
RawHereDocument,
HereDocument,
HereDocumentEnd,
Expand Down Expand Up @@ -202,7 +210,18 @@ typedef enum {
Argument,
List,
Default,
Undefined
Pod,
Comment,
WhiteSpace,
Undefined,
PostDeref,
PostDerefStar,
PostDerefArraySliceOpenBracket,
PostDerefArraySliceCloseBracket,
PostDerefHashSliceOpenBrace,
PostDerefHashSliceCloseBrace,
PostDerefCodeOpenParen,
PostDerefCodeCloseParen
} Type;
}

Expand All @@ -222,13 +241,8 @@ typedef enum {
CORE,
DESTROY,
Handle,
Redo,
Next,
Last,
Goto,
Continue,
Control,
Do,
Break,
Module,
Stmt,
DefaultStmt,
Expand All @@ -248,6 +262,7 @@ typedef enum {
Ref,
Get,
Set,
Verbose,
Undefined
} Kind;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Compiler/CodeGenerator/LLVM.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Compiler::CodeGenerator::LLVM;
use v5.008_001;
use 5.008_001;
use strict;
use warnings;
use File::Basename qw/dirname/;
Expand Down
Loading