mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-23 19:59:57 +00:00
[Examples] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26433 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a7f010bf7
commit
38ccacb5ed
@ -93,7 +93,6 @@ public:
|
||||
void removeModule(ModuleHandle H) {
|
||||
CompileLayer.removeModuleSet(H);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end namespace orc
|
||||
|
@ -7,15 +7,13 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -135,11 +133,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -149,6 +150,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -158,8 +160,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -170,6 +173,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -182,6 +186,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -194,6 +199,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -205,6 +211,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -219,6 +226,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -232,6 +240,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -249,6 +258,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -272,8 +282,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -25,10 +25,13 @@
|
||||
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
|
||||
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -105,7 +108,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
|
||||
// Create a function pass manager.
|
||||
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
|
||||
@ -124,7 +126,6 @@ private:
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end namespace orc
|
||||
|
@ -7,15 +7,13 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -135,11 +133,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -149,6 +150,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -158,8 +160,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -170,6 +173,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -182,6 +186,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -194,6 +199,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -205,6 +211,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -219,6 +226,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -232,6 +240,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -249,6 +258,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -272,8 +282,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -26,12 +26,16 @@
|
||||
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
|
||||
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -116,7 +120,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
|
||||
// Create a function pass manager.
|
||||
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
|
||||
@ -135,7 +138,6 @@ private:
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end namespace orc
|
||||
|
@ -7,15 +7,13 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -135,11 +133,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -149,6 +150,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -158,8 +160,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -170,6 +173,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -182,6 +186,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -194,6 +199,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -205,6 +211,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -219,6 +226,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -232,6 +240,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -249,6 +258,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -272,8 +282,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -26,11 +26,17 @@
|
||||
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
|
||||
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -47,6 +53,7 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
const PrototypeAST& getProto() const;
|
||||
const std::string& getName() const;
|
||||
llvm::Function *codegen();
|
||||
@ -197,7 +204,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::string mangle(const std::string &Name) {
|
||||
std::string MangledName;
|
||||
raw_string_ostream MangledNameStream(MangledName);
|
||||
@ -223,7 +229,6 @@ private:
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end namespace orc
|
||||
|
@ -7,16 +7,15 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -140,7 +139,8 @@ static int gettok() {
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -150,6 +150,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -159,8 +160,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -171,6 +173,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -183,6 +186,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -195,6 +199,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -206,6 +211,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -220,6 +226,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -233,6 +240,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -250,6 +258,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
|
@ -15,11 +15,12 @@
|
||||
#define LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
|
||||
|
||||
#include "RemoteJITUtils.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||
#include "llvm/ExecutionEngine/JITSymbol.h"
|
||||
#include "llvm/ExecutionEngine/RuntimeDyld.h"
|
||||
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
|
||||
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
|
||||
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
|
||||
@ -28,11 +29,17 @@
|
||||
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
|
||||
#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Mangler.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -49,6 +56,7 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
const PrototypeAST& getProto() const;
|
||||
const std::string& getName() const;
|
||||
llvm::Function *codegen();
|
||||
@ -229,7 +237,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::string mangle(const std::string &Name) {
|
||||
std::string MangledName;
|
||||
raw_string_ostream MangledNameStream(MangledName);
|
||||
@ -255,7 +262,6 @@ private:
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end namespace orc
|
||||
|
@ -15,8 +15,10 @@
|
||||
#define LLVM_TOOLS_LLI_REMOTEJITUTILS_H
|
||||
|
||||
#include "llvm/ExecutionEngine/Orc/RawByteChannel.h"
|
||||
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
|
||||
#include <mutex>
|
||||
#include "llvm/Support/Error.h"
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <system_error>
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
#include <unistd.h>
|
||||
@ -71,4 +73,4 @@ private:
|
||||
int InFD, OutFD;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // LLVM_TOOLS_LLI_REMOTEJITUTILS_H
|
||||
|
@ -7,29 +7,30 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "KaleidoscopeJIT.h"
|
||||
#include "RemoteJITUtils.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -155,7 +156,8 @@ static int gettok() {
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -165,6 +167,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -174,8 +177,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -186,6 +190,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -198,6 +203,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -210,6 +216,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -221,6 +228,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -235,6 +243,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -248,6 +257,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -265,6 +275,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -1229,9 +1240,9 @@ std::unique_ptr<FDRPCChannel> connect() {
|
||||
}
|
||||
|
||||
sockaddr_in servAddr;
|
||||
bzero(&servAddr, sizeof(servAddr));
|
||||
memset(&servAddr, 0, sizeof(servAddr));
|
||||
servAddr.sin_family = PF_INET;
|
||||
bcopy(server->h_addr, &servAddr.sin_addr.s_addr, server->h_length);
|
||||
memcpy(&servAddr.sin_addr.s_addr, server->h_addr, server->h_length);
|
||||
servAddr.sin_port = htons(Port);
|
||||
if (connect(sockfd, reinterpret_cast<sockaddr*>(&servAddr),
|
||||
sizeof(servAddr)) < 0) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@ -82,11 +83,13 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
};
|
||||
|
||||
/// NumberExprAST - Expression class for numeric literals like "1.0".
|
||||
@ -149,6 +152,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@ -94,11 +95,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -108,6 +112,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -117,6 +122,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -129,6 +135,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -141,6 +148,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -154,6 +162,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(const std::string &Name, std::vector<std::string> Args)
|
||||
: Name(Name), Args(std::move(Args)) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
@ -167,8 +176,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "../include/KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -103,11 +104,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -117,6 +121,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -126,6 +131,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -138,6 +144,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -150,6 +157,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -163,6 +171,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(const std::string &Name, std::vector<std::string> Args)
|
||||
: Name(Name), Args(std::move(Args)) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
@ -176,8 +185,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "../include/KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -121,11 +122,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -135,6 +139,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -144,6 +149,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -156,6 +162,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -168,6 +175,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -179,6 +187,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -193,6 +202,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -206,6 +216,7 @@ class PrototypeAST {
|
||||
public:
|
||||
PrototypeAST(const std::string &Name, std::vector<std::string> Args)
|
||||
: Name(Name), Args(std::move(Args)) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
@ -219,8 +230,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "../include/KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -129,11 +130,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -143,6 +147,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -152,6 +157,7 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -163,6 +169,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -175,6 +182,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -187,6 +195,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -198,6 +207,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -212,6 +222,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -229,6 +240,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -252,8 +264,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Scalar/GVN.h"
|
||||
#include "../include/KaleidoscopeJIT.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
@ -135,11 +136,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -149,6 +153,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -158,8 +163,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -170,6 +176,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -182,6 +189,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -194,6 +202,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -205,6 +214,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -219,6 +229,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -232,6 +243,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -249,6 +261,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -272,8 +285,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -1,26 +1,33 @@
|
||||
#include "llvm/ADT/APFloat.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Host.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -132,11 +139,14 @@ static int gettok() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Abstract Syntax Tree (aka Parse Tree)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// ExprAST - Base class for all expression nodes.
|
||||
class ExprAST {
|
||||
public:
|
||||
virtual ~ExprAST() {}
|
||||
virtual ~ExprAST() = default;
|
||||
|
||||
virtual Value *codegen() = 0;
|
||||
};
|
||||
|
||||
@ -146,6 +156,7 @@ class NumberExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
NumberExprAST(double Val) : Val(Val) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -155,8 +166,9 @@ class VariableExprAST : public ExprAST {
|
||||
|
||||
public:
|
||||
VariableExprAST(const std::string &Name) : Name(Name) {}
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
Value *codegen() override;
|
||||
const std::string &getName() const { return Name; }
|
||||
};
|
||||
|
||||
/// UnaryExprAST - Expression class for a unary operator.
|
||||
@ -167,6 +179,7 @@ class UnaryExprAST : public ExprAST {
|
||||
public:
|
||||
UnaryExprAST(char Opcode, std::unique_ptr<ExprAST> Operand)
|
||||
: Opcode(Opcode), Operand(std::move(Operand)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -179,6 +192,7 @@ public:
|
||||
BinaryExprAST(char Op, std::unique_ptr<ExprAST> LHS,
|
||||
std::unique_ptr<ExprAST> RHS)
|
||||
: Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -191,6 +205,7 @@ public:
|
||||
CallExprAST(const std::string &Callee,
|
||||
std::vector<std::unique_ptr<ExprAST>> Args)
|
||||
: Callee(Callee), Args(std::move(Args)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -202,6 +217,7 @@ public:
|
||||
IfExprAST(std::unique_ptr<ExprAST> Cond, std::unique_ptr<ExprAST> Then,
|
||||
std::unique_ptr<ExprAST> Else)
|
||||
: Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -216,6 +232,7 @@ public:
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarName(VarName), Start(std::move(Start)), End(std::move(End)),
|
||||
Step(std::move(Step)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -229,6 +246,7 @@ public:
|
||||
std::vector<std::pair<std::string, std::unique_ptr<ExprAST>>> VarNames,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: VarNames(std::move(VarNames)), Body(std::move(Body)) {}
|
||||
|
||||
Value *codegen() override;
|
||||
};
|
||||
|
||||
@ -246,6 +264,7 @@ public:
|
||||
bool IsOperator = false, unsigned Prec = 0)
|
||||
: Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
|
||||
Precedence(Prec) {}
|
||||
|
||||
Function *codegen();
|
||||
const std::string &getName() const { return Name; }
|
||||
|
||||
@ -269,8 +288,10 @@ public:
|
||||
FunctionAST(std::unique_ptr<PrototypeAST> Proto,
|
||||
std::unique_ptr<ExprAST> Body)
|
||||
: Proto(std::move(Proto)), Body(std::move(Body)) {}
|
||||
|
||||
Function *codegen();
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Loading…
Reference in New Issue
Block a user