LLVMBasicBlock.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 21 Apr 2016 22:17:02 +0100
changeset 61 c2e287d54de5
parent 58 6b9f8fec013a
child 62 2936ec426df6
permissions -rw-r--r--
Added support for PHI nodes. Even though manual use of these is discouraged, this may be very handy when one needs to generate `cond ? tval : fval` kind of expression. In some cases one may not use `select` instructions is nay compile to CMOV on Intel which has its issues and may lead to SEGV.

"
    Copyright (C) 2015-now Jan Vrany

    This code is not an open-source (yet). You may use this code
    for your own experiments and projects, given that:

    * all modification to the code will be sent to the
      original author for inclusion in future releases
    * this is not used in any commercial software

    This license is provisional and may (will) change in
    a future.
"
"{ Package: 'jv:llvm_s' }"

"{ NameSpace: Smalltalk }"

LLVMObject subclass:#LLVMBasicBlock
	instanceVariableNames:'function'
	classVariableNames:''
	poolDictionaries:''
	category:'LLVM-S-Core'
!

!LLVMBasicBlock class methodsFor:'documentation'!

copyright
"
    Copyright (C) 2015-now Jan Vrany

    This code is not an open-source (yet). You may use this code
    for your own experiments and projects, given that:

    * all modification to the code will be sent to the
      original author for inclusion in future releases
    * this is not used in any commercial software

    This license is provisional and may (will) change in
    a future.
"
! !

!LLVMBasicBlock methodsFor:'accessing'!

builder
    "Return a builder positioned at the end of the receiver"
    
    | builder |

    builder := LLVMIRBuilder new.
    builder positionAtEnd:self.
    ^ builder

    "Created: / 08-08-2015 / 03:25:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

function
    ^ function

    "Created: / 08-08-2015 / 03:22:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

lastInstruction
    ^ LLVM GetLastInstruction: self.

    "Created: / 20-04-2016 / 22:02:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LLVMBasicBlock methodsFor:'converting'!

asLLVMValue
    "Return representation of the receiver as LLVMValue"

    ^ LLVM BasicBlockAsValue: self

    "Created: / 08-08-2015 / 02:11:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

asLLVMasicBlock
    ^ self.

    "Created: / 21-04-2016 / 22:11:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LLVMBasicBlock methodsFor:'initialization'!

function:anLLVMFunction
    function := anLLVMFunction.

    "Created: / 08-08-2015 / 03:22:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!LLVMBasicBlock methodsFor:'testing'!

isLLVMBasicBlock
    ^ true

    "Created: / 21-04-2016 / 22:29:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !