-
Notifications
You must be signed in to change notification settings - Fork 29
Add ConstantAggregateZero ConstantExpr and a few more methods #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vihanb
wants to merge
30
commits into
MichaReiser:master
Choose a base branch
from
vsl-lang:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
112c2b8
Add ConstantExpr
vihanb b67b94b
Add a couple more methods
vihanb 7547c2c
Add ConstantExpr.getBitCast
vihanb 0242e53
Add DataLayout.getTypeAllocSize function
vihanb 9e7208a
Add DataLayout.getTypeAllocSizeInBits
vihanb e078096
Add IntegerType class.
vihanb 77dafe3
Merge branch 'add-getTypeAllocSize'
vihanb 894dbf2
Add ConstantAggregateZero class
vihanb 5c215c5
Add missing to IR
vihanb e066518
Add GEP for ConstantExpr
vihanb b3809c0
Use constant GEP.
vihanb 366bb2e
Add IsNull call
vihanb fed76a6
Add unsigned remainder to IR builder
vihanb eac8051
Add casting functions
vihanb 641984f
Merge remote-tracking branch 'upstream/master'
vihanb 55f1f55
Merge remote-tracking branch 'upstream/master'
vihanb 75ebf64
Add createIntToPtr and also address review comments
vihanb 10cbb3a
Merge branch 'master' into master
vihanb 170fc44
Fix tests and also add last method forgot to put
vihanb cac32ed
Add missing udiv
vihanb 33eacb7
Oops
vihanb 4690747
Fix IRBuilder tests, not sure why they were this way.
vihanb b45fd26
.bitWidth -> .getBitWidth() and other test fixes
vihanb a1ab7ba
Add floating point isNaN operation effectively
vihanb 700295a
Add 'createUnreachable'
vihanb 3357b27
Merge remote-tracking branch 'upstream/master'
vihanb 76fad39
Merge remote-tracking branch 'refs/remotes/origin/master'
vihanb 35b7014
Merge remote-tracking branch 'upstream/master'
vihanb 9be0aa7
Add atomicRMW
vihanb 827a1b3
Remove invalid fops for rmw operations.
vihanb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <llvm/IR/Instructions.h> | ||
#include "atomic-rmw-inst.h" | ||
|
||
NAN_MODULE_INIT(InitAtomicRMWInst) { | ||
auto atomicRMWInst = Nan::New<v8::Object>(); | ||
|
||
auto binOp = Nan::New<v8::Object>(); | ||
Nan::Set(binOp, Nan::New("Add").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Add))); | ||
Nan::Set(binOp, Nan::New("Sub").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Sub))); | ||
Nan::Set(binOp, Nan::New("And").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::And))); | ||
Nan::Set(binOp, Nan::New("Nand").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Nand))); | ||
Nan::Set(binOp, Nan::New("Or").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Or))); | ||
Nan::Set(binOp, Nan::New("Xor").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Xor))); | ||
Nan::Set(binOp, Nan::New("Max").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Max))); | ||
Nan::Set(binOp, Nan::New("Min").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::Min))); | ||
Nan::Set(binOp, Nan::New("UMax").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::UMax))); | ||
Nan::Set(binOp, Nan::New("UMin").ToLocalChecked(), Nan::New(static_cast<uint32_t>(llvm::AtomicRMWInst::BinOp::UMin))); | ||
|
||
Nan::Set(atomicRMWInst, Nan::New("BinOp").ToLocalChecked(), binOp); | ||
|
||
Nan::Set(target, Nan::New("AtomicRMWInst").ToLocalChecked(), atomicRMWInst); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef LLVM_ATOMIC_RMW_INST_H | ||
#define LLVM_ATOMIC_RMW_INST_H | ||
|
||
#include <nan.h> | ||
|
||
NAN_MODULE_INIT(InitAtomicRMWInst); | ||
|
||
#endif //LLVM_ATOMIC_RMW_INST_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "constant-aggregate-zero.h" | ||
#include "type.h" | ||
|
||
NAN_MODULE_INIT(ConstantAggregateZeroWrapper::Init) { | ||
auto constantAggregateZero = Nan::GetFunction(Nan::New(constantAggregateZeroTemplate())).ToLocalChecked(); | ||
|
||
Nan::Set(target, Nan::New("ConstantAggregateZero").ToLocalChecked(), constantAggregateZero); | ||
} | ||
|
||
v8::Local<v8::Object> ConstantAggregateZeroWrapper::of(llvm::ConstantAggregateZero* constantAggregateZero) { | ||
auto constructor = Nan::GetFunction(Nan::New(constantAggregateZeroTemplate())).ToLocalChecked(); | ||
v8::Local<v8::Value> args[1] = { Nan::New<v8::External> (constantAggregateZero) }; | ||
|
||
auto instance = Nan::NewInstance(constructor, 1, args).ToLocalChecked(); | ||
|
||
Nan::EscapableHandleScope escapableHandleScope {}; | ||
return escapableHandleScope.Escape(instance); | ||
} | ||
|
||
llvm::ConstantAggregateZero* ConstantAggregateZeroWrapper::getConstantAggregateZero() { | ||
return static_cast<llvm::ConstantAggregateZero*>(getValue()); | ||
} | ||
|
||
Nan::Persistent<v8::FunctionTemplate>& ConstantAggregateZeroWrapper::constantAggregateZeroTemplate() { | ||
static Nan::Persistent<v8::FunctionTemplate> functionTemplate {}; | ||
|
||
if (functionTemplate.IsEmpty()) { | ||
v8::Local<v8::FunctionTemplate> localTemplate = Nan::New<v8::FunctionTemplate>(ConstantAggregateZeroWrapper::New); | ||
localTemplate->SetClassName(Nan::New("ConstantAggregateZero").ToLocalChecked()); | ||
localTemplate->InstanceTemplate()->SetInternalFieldCount(1); | ||
localTemplate->Inherit(Nan::New(constantTemplate())); | ||
|
||
Nan::SetMethod(localTemplate, "get", ConstantAggregateZeroWrapper::get); | ||
|
||
functionTemplate.Reset(localTemplate); | ||
} | ||
|
||
return functionTemplate; | ||
} | ||
|
||
NAN_METHOD(ConstantAggregateZeroWrapper::New) { | ||
if (!info.IsConstructCall()) { | ||
return Nan::ThrowTypeError("ConstantAggregateZero constructor needs to be called with new"); | ||
} | ||
|
||
if (!info[0]->IsExternal()) { | ||
return Nan::ThrowTypeError("ConstantAggregateZero constructor needs to be called with: constantAggregateZero: External"); | ||
} | ||
|
||
auto* constantAggregateZero = static_cast<llvm::ConstantAggregateZero*>(v8::External::Cast(*info[0])->Value()); | ||
auto* wrapper = new ConstantAggregateZeroWrapper { constantAggregateZero }; | ||
wrapper->Wrap(info.This()); | ||
|
||
info.GetReturnValue().Set(info.This()); | ||
} | ||
|
||
|
||
NAN_METHOD(ConstantAggregateZeroWrapper::get) { | ||
if (info.Length() != 1 || !TypeWrapper::isInstance(info[0])) { | ||
return Nan::ThrowTypeError("get needs to be called with: type: Type"); | ||
} | ||
|
||
auto* type = TypeWrapper::FromValue(info[0])->getType(); | ||
auto constantAggregateZero = llvm::ConstantAggregateZero::get(type); | ||
|
||
info.GetReturnValue().Set(ConstantWrapper::of(constantAggregateZero)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef LLVM_NODE_CONSTANT_AGGREGATE_ZERO_H | ||
#define LLVM_NODE_CONSTANT_AGGREGATE_ZERO_H | ||
|
||
#include <nan.h> | ||
#include <llvm/IR/Constants.h> | ||
#include "constant.h" | ||
|
||
class ConstantAggregateZeroWrapper: public ConstantWrapper, public FromValueMixin<ConstantAggregateZeroWrapper> { | ||
public: | ||
static NAN_MODULE_INIT(Init); | ||
static v8::Local<v8::Object> of(llvm::ConstantAggregateZero* constantAggregateZero); | ||
using FromValueMixin<ConstantAggregateZeroWrapper>::FromValue; | ||
llvm::ConstantAggregateZero* getConstantAggregateZero(); | ||
|
||
private: | ||
explicit ConstantAggregateZeroWrapper(llvm::ConstantAggregateZero* constantAggregateZero) : ConstantWrapper { constantAggregateZero } | ||
{} | ||
|
||
static Nan::Persistent<v8::FunctionTemplate>& constantAggregateZeroTemplate(); | ||
|
||
static NAN_METHOD(New); | ||
static NAN_METHOD(get); | ||
}; | ||
|
||
#endif //LLVM_NODE_CONSTANT_AGGREGATE_ZERO_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find this method in the LLVM documentation nor that it is implemented in this PR. should this (and the following method be declared on DataLayout instead)?