Skip to content

Commit

Permalink
Add LLVM::Constant
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 6, 2011
1 parent d473cea commit 262226c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
31 changes: 31 additions & 0 deletions runtime/parrot/library/LLVM.pm
Expand Up @@ -9,6 +9,37 @@ module LLVM {
LLVMModuleCreateWithName => "pt",
LLVMDumpModule => "vp",

# Operations on constants of any type
LLVMConstNull => "pp",
LLVMConstAllOnes => "pp",
LLVMGetUndef => "pp",
LLVMIsConstant => "ip",
LLVMIsNull => "ip",
LLVMIsUndef => "ip",
LLVMConstPointerNull => "pp",

# Operations on scalar constants
LLVMConstInt => "ppii",
LLVMConstIntOfString => "ppti",
LLVMConstIntOfStringAndSize => "pptii",
LLVMConstReal => "ppd",
LLVMConstRealOfString => "ppt",
LLVMConstRealOfStringAndSize => "ppti",


# Operations on composite constants
LLVMConstStringInContext => "pptii",
LLVMConstStructInContext => "pppii",

LLVMConstString => "ptii",
LLVMConstArray => "pppi", # FIXME
LLVMConstStruct => "ppii", # FIXME
LLVMConstVector => "ppi", #FIXME

# Constant expressions
LLVMAlignOf => "pp",
LLVMSizeOf => "pp",

# See llvm::LLVMTypeKind::getTypeID.
LLVMGetTypeKind => "ip",

Expand Down
13 changes: 13 additions & 0 deletions runtime/parrot/library/LLVM/Constant.pm
@@ -0,0 +1,13 @@
module LLVM::Constant {

sub null($type) {
%LLVM::F<LLVMConstNull>($type);
}

sub string($str) {
%LLVM::F<LLVMConstString>(~$str, pir::length($str), 0);
}

};

# vim: ft=perl6
4 changes: 4 additions & 0 deletions runtime/parrot/library/Rules.mak
Expand Up @@ -27,6 +27,7 @@ $(LIBRARY_DIR)/LLVM.pbc : \
$(LIBRARY_DIR)/LLVM.pir \
$(LIBRARY_DIR)/LLVM/BasicBlock.pir \
$(LIBRARY_DIR)/LLVM/Builder.pir \
$(LIBRARY_DIR)/LLVM/Constant.pir \
$(LIBRARY_DIR)/LLVM/Function.pir \
$(LIBRARY_DIR)/LLVM/Module.pir \
$(LIBRARY_DIR)/LLVM/Type.pir
Expand All @@ -41,6 +42,9 @@ $(LIBRARY_DIR)/LLVM/BasicBlock.pir: $(NQP_RX) $(LIBRARY_DIR)/LLVM/BasicBlock.pm
$(LIBRARY_DIR)/LLVM/Builder.pir: $(NQP_RX) $(LIBRARY_DIR)/LLVM/Builder.pm
$(NQP_RX) --target=pir --output=$@ $(LIBRARY_DIR)/LLVM/Builder.pm

$(LIBRARY_DIR)/LLVM/Constant.pir: $(NQP_RX) $(LIBRARY_DIR)/LLVM/Constant.pm
$(NQP_RX) --target=pir --output=$@ $(LIBRARY_DIR)/LLVM/Constant.pm

$(LIBRARY_DIR)/LLVM/Function.pir: $(NQP_RX) $(LIBRARY_DIR)/LLVM/Function.pm
$(NQP_RX) --target=pir --output=$@ $(LIBRARY_DIR)/LLVM/Function.pm

Expand Down
1 change: 1 addition & 0 deletions runtime/parrot/library/llvm_lib.pir
Expand Up @@ -2,6 +2,7 @@
.include "runtime/parrot/library/LLVM.pir"
.include "runtime/parrot/library/LLVM/BasicBlock.pir"
.include "runtime/parrot/library/LLVM/Builder.pir"
.include "runtime/parrot/library/LLVM/Constant.pir"
.include "runtime/parrot/library/LLVM/Function.pir"
.include "runtime/parrot/library/LLVM/Type.pir"
.include "runtime/parrot/library/LLVM/Module.pir"

0 comments on commit 262226c

Please sign in to comment.