aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/ArrayHandler.cc5
-rw-r--r--lib/CodeGen/ArrayOutput.cc3
-rw-r--r--lib/CodeGen/ArrayParameters.cc3
-rw-r--r--lib/CodeGen/CodeGen.cc3
-rw-r--r--lib/CodeGen/ConstantGen.cc1
-rw-r--r--lib/CodeGen/ConstructorGen.cc6
-rw-r--r--lib/CodeGen/FunctionGen.cc3
-rw-r--r--lib/CodeGen/OperatorGen.cc2
-rw-r--r--lib/CodeGen/StatementGen.cc2
-rw-r--r--lib/CodeGen/ValueTypeGen.cc4
10 files changed, 11 insertions, 21 deletions
diff --git a/lib/CodeGen/ArrayHandler.cc b/lib/CodeGen/ArrayHandler.cc
index 1cace28..bfe6a78 100644
--- a/lib/CodeGen/ArrayHandler.cc
+++ b/lib/CodeGen/ArrayHandler.cc
@@ -4,7 +4,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Type.h"
-#include <cstdio>
using namespace llvm;
using namespace cps;
@@ -214,7 +213,7 @@ bool ArrayHandler::emitCheckedIndices(const std::string &Name,
return true;
}
-Value *ArrayHandler::loadElement(const std::string &Name, Value *Offset, CodeGen &CG) {
+Value *ArrayHandler::loadElement(const std::string &Name, Value *Offset) {
const ArrayMetadata *Meta = getMetadata(Name);
if (!Meta) return nullptr;
@@ -232,7 +231,7 @@ Value *ArrayHandler::emitArrayAccess(ArrayAccessExprAST *Expr, CodeGen &CG) {
return nullptr;
Value *Offset = computeFlatIndex(Name, Indices);
- return loadElement(Name, Offset, CG);
+ return loadElement(Name, Offset);
}
void ArrayHandler::emitArrayAssign(ArrayAssignStmtAST *Stmt, CodeGen &CG) {
diff --git a/lib/CodeGen/ArrayOutput.cc b/lib/CodeGen/ArrayOutput.cc
index 91e9f49..9306823 100644
--- a/lib/CodeGen/ArrayOutput.cc
+++ b/lib/CodeGen/ArrayOutput.cc
@@ -4,7 +4,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Type.h"
-#include <cstdio>
using namespace llvm;
using namespace cps;
@@ -55,7 +54,7 @@ void ArrayHandler::emitPrintLoop(const std::string &Name,
if (CurrentDim == Meta->Rank) {
Value *Offset = computeFlatIndex(Name, CurrentIndices);
- Value *Val = loadElement(Name, Offset, CG);
+ Value *Val = loadElement(Name, Offset);
if (!Val) return;
CG.emitOutputValue(Val, Types.resolve(Meta->ElementTypeName), true);
diff --git a/lib/CodeGen/ArrayParameters.cc b/lib/CodeGen/ArrayParameters.cc
index a5f0beb..4f2d54d 100644
--- a/lib/CodeGen/ArrayParameters.cc
+++ b/lib/CodeGen/ArrayParameters.cc
@@ -4,7 +4,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Type.h"
-#include <cstdio>
using namespace llvm;
using namespace cps;
@@ -82,7 +81,7 @@ void ArrayHandler::bindArrayParameter(const std::string &Name,
CG.registerSymbol(Name, Alloca, ElemInfo->Name, true);
if (MakeCopy)
- CG.activateStackObject(CG.registerStackObject(Alloca, ElemInfo->Name, 0, true, true), TotalElements);
+ CG.activateStackObject(CG.registerStackObject(Alloca, ElemInfo->Name, 0, true), TotalElements);
}
bool ArrayHandler::emitArrayArgument(ExprAST *ArgExpr,
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc
index 7b58b5b..4137761 100644
--- a/lib/CodeGen/CodeGen.cc
+++ b/lib/CodeGen/CodeGen.cc
@@ -12,7 +12,6 @@
#include "llvm/IR/Verifier.h"
#include <algorithm>
#include <cstdarg>
-#include <cstdio>
using namespace llvm;
using namespace cps;
@@ -75,7 +74,7 @@ CodeGen::CodeGen() {
});
FuncGen->setCopyRegistrar([this](Value *Addr, const std::string &TypeName, int Line) {
- activateStackObject(registerStackObject(Addr, TypeName, Line, false, true));
+ activateStackObject(registerStackObject(Addr, TypeName, Line));
});
SetupExternalFunctions();
diff --git a/lib/CodeGen/ConstantGen.cc b/lib/CodeGen/ConstantGen.cc
index ca96834..a512490 100644
--- a/lib/CodeGen/ConstantGen.cc
+++ b/lib/CodeGen/ConstantGen.cc
@@ -1,6 +1,5 @@
#include "cps/Diagnostics.h"
#include "cps/CodeGen.h"
-#include <cstdio>
using namespace llvm;
using namespace cps;
diff --git a/lib/CodeGen/ConstructorGen.cc b/lib/CodeGen/ConstructorGen.cc
index dfdfbb5..429138a 100644
--- a/lib/CodeGen/ConstructorGen.cc
+++ b/lib/CodeGen/ConstructorGen.cc
@@ -70,7 +70,7 @@ Value *CodeGen::copyClassValue(const TypeInfo *Type, Value *Address,
if (!checkOperatorAccess(*Copy)) return nullptr;
auto *Storage = CreateEntryBlockAlloca(Builder->GetInsertBlock()->getParent(),
Type->LLVMType, "copy_object");
- size_t Lifetime = registerStackObject(Storage, Type->Name, DiagnosticLine, false, true);
+ size_t Lifetime = registerStackObject(Storage, Type->Name, DiagnosticLine);
if (Lifetime != size_t(-1)) StackObjects[Lifetime].Temporary = true;
Builder->CreateStore(Types->getZeroValue(Type->Name), Storage);
for (const auto &[Name, Field] : Type->Record.Fields) {
@@ -255,7 +255,7 @@ bool CodeGen::emitDestroy(const std::string &TypeName, Value *Addr, int Line) {
}
size_t CodeGen::registerStackObject(Value *Addr, const std::string &TypeName, int Line,
- bool IsArray, bool IsCopy) {
+ bool IsArray) {
if (!typeNeedsDestruction(TypeName)) return size_t(-1);
auto *F = Builder->GetInsertBlock()->getParent();
IRBuilder<> Entry(&F->getEntryBlock(), F->getEntryBlock().begin());
@@ -266,7 +266,7 @@ size_t CodeGen::registerStackObject(Value *Addr, const std::string &TypeName, in
Count = Entry.CreateAlloca(Entry.getInt64Ty(), nullptr, "object_count");
Entry.CreateStore(Entry.getInt64(0), Count);
}
- StackObjects.push_back({Addr, TypeName, Alive, Count, Line, IsCopy});
+ StackObjects.push_back({Addr, TypeName, Alive, Count, Line});
// This DECLARE can execute repeatedly, including after a backward loop edge.
emitStackObjectCleanup(StackObjects.back());
return StackObjects.size() - 1;
diff --git a/lib/CodeGen/FunctionGen.cc b/lib/CodeGen/FunctionGen.cc
index 628f3ba..9c9d0f5 100644
--- a/lib/CodeGen/FunctionGen.cc
+++ b/lib/CodeGen/FunctionGen.cc
@@ -3,7 +3,6 @@
#include "cps/CodeGen.h"
#include "cps/ExceptionHandler.h"
#include "cps/Operator.h"
-#include <cstdio>
#include <cstdarg>
using namespace llvm;
@@ -472,7 +471,7 @@ llvm::Value *FunctionGen::emitCall(const FuncSig &Sig, const std::vector<llvm::V
return Call;
}
-void FunctionGen::emitReturn(ReturnStmtAST *Ret, llvm::Value *RetVal) {
+void FunctionGen::emitReturn(llvm::Value *RetVal) {
Instruction *CatchCleanup = Exceptions.emitReturnCleanup();
Instruction *RetInst = RetVal ? Builder.CreateRet(RetVal) : Builder.CreateRetVoid();
Exceptions.recordExit(CatchCleanup ? CatchCleanup : RetInst);
diff --git a/lib/CodeGen/OperatorGen.cc b/lib/CodeGen/OperatorGen.cc
index 67fd1e4..0963e05 100644
--- a/lib/CodeGen/OperatorGen.cc
+++ b/lib/CodeGen/OperatorGen.cc
@@ -42,7 +42,7 @@ Value *CodeGen::materializeOperatorReceiver(Value *Val, const TypeInfo *Type) {
if (!Val || !Type) return nullptr;
auto *Storage = CreateEntryBlockAlloca(Builder->GetInsertBlock()->getParent(),
Type->LLVMType, "operator_receiver");
- size_t Object = registerStackObject(Storage, Type->Name, DiagnosticLine, false, true);
+ size_t Object = registerStackObject(Storage, Type->Name, DiagnosticLine);
Builder->CreateStore(Val, Storage);
activateStackObject(Object);
if (Object != size_t(-1)) StackObjects[Object].Temporary = true;
diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc
index 7a73e51..40fe394 100644
--- a/lib/CodeGen/StatementGen.cc
+++ b/lib/CodeGen/StatementGen.cc
@@ -137,7 +137,7 @@ void CodeGen::emitStmtImpl(StmtAST *Stmt) {
if (!RetVal) return;
}
cleanupTemporaries();
- FuncGen->emitReturn(Ret, RetVal);
+ FuncGen->emitReturn(RetVal);
return;
}
diff --git a/lib/CodeGen/ValueTypeGen.cc b/lib/CodeGen/ValueTypeGen.cc
index 1079b14..e73b189 100644
--- a/lib/CodeGen/ValueTypeGen.cc
+++ b/lib/CodeGen/ValueTypeGen.cc
@@ -161,7 +161,6 @@ Value *CodeGen::coerceValueToType(Value *Val, const TypeInfo *TargetInfo) {
switch (TargetInfo->Kind) {
case TypeKind::Real:
- if (Val->getType()->isDoubleTy()) return Val;
if (Val->getType()->isIntegerTy(1))
return Builder->CreateUIToFP(Val, Type::getDoubleTy(*TheContext), "bool_to_real");
if (Val->getType()->isIntegerTy(8))
@@ -171,7 +170,6 @@ Value *CodeGen::coerceValueToType(Value *Val, const TypeInfo *TargetInfo) {
break;
case TypeKind::Integer:
- if (Val->getType()->isIntegerTy(64)) return Val;
if (Val->getType()->isDoubleTy())
return Builder->CreateFPToSI(Val, Type::getInt64Ty(*TheContext), "real_to_int");
if (Val->getType()->isIntegerTy(1))
@@ -183,7 +181,6 @@ Value *CodeGen::coerceValueToType(Value *Val, const TypeInfo *TargetInfo) {
break;
case TypeKind::Boolean:
- if (Val->getType()->isIntegerTy(1)) return Val;
if (Val->getType()->isIntegerTy())
return Builder->CreateICmpNE(Val, Constant::getNullValue(Val->getType()), "to_bool");
if (Val->getType()->isDoubleTy())
@@ -195,7 +192,6 @@ Value *CodeGen::coerceValueToType(Value *Val, const TypeInfo *TargetInfo) {
break;
case TypeKind::Char:
- if (Val->getType()->isIntegerTy(8)) return Val;
if (Val->getType()->isIntegerTy(1))
return Builder->CreateZExt(Val, Type::getInt8Ty(*TheContext), "bool_to_char");
if (Val->getType()->isDoubleTy())