extensions.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 06 Jul 2016 22:40:59 +0100
changeset 71 ab03b0a6d037
parent 61 c2e287d54de5
permissions -rw-r--r--
Implemented LLVMType>>sizeInBits/sizeInBytes for all data types ...i.e., also for structures, vectors and arrays.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
f98e97fd02ef Package renamed from jv:libllvms to jv:llvm_s
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
     1
"{ Package: 'jv:llvm_s' }"!
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
22
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     3
!Object methodsFor:'converting'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     4
61
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
     5
asLLVMBasicBlock
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
     6
    "Return representation of the receiver as LLVMBasicBlock"
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
     7
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
     8
    "Raise an error - arbitrary object cannot be represented
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
     9
     as LLVM value"
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    10
    self error: 'cannot be converted to an LLVM basic block'
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    11
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    12
    "Created: / 21-04-2016 / 22:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    13
! !
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    14
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    15
!Object methodsFor:'converting'!
c2e287d54de5 Added support for PHI nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 46
diff changeset
    16
33
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    17
asLLVMMetadata
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    18
    "Return representation of the receiver as LLVMMetadata."
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    19
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    20
    "Raise an error - arbitrary object cannot be represented
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    21
     as LLVM metadata"
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    22
    self error: 'cannot be converted to an LLVM metadata'
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    23
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    24
    "Created: / 15-08-2015 / 06:43:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    25
! !
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    26
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    27
!Object methodsFor:'converting'!
feabf14b6c1d Initial support for generating (DWARF) debug info.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 24
diff changeset
    28
22
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    29
asLLVMValue
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    30
    "Return representation of the receiver as LLVMValue."
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    31
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    32
    "Raise an error - arbitrary object cannot be represented
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    33
     as LLVM value"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    34
    self error: 'cannot be converted to an LLVM value'
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    35
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    36
    "Created: / 08-08-2015 / 02:11:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    37
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    38
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    39
!Object methodsFor:'converting'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    40
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    41
asLLVMValueOfType: anLLVMType
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    42
    "Return representation of the receiver as LLVMValue with given LLVMType. 
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    43
     If the object cannot be converted to the balue of requested type, 
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    44
     raise an error."
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    45
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    46
    self error: 'cannot be converted to an LLVM value'
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    47
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    48
    "Created: / 08-08-2015 / 02:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    49
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    50
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    51
!Object methodsFor:'testing'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    52
24
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    53
isLLVMFunction
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    54
    "Return true, if receiver represents an LLVM value representing a function"
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    55
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    56
    ^ false
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    57
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    58
    "Created: / 10-08-2015 / 19:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    59
! !
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    60
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    61
!Object methodsFor:'testing'!
7e7ddd55174c Added support for intrinsics.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
    62
22
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    63
isLLVMType
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    64
    "Return true, if receiver represents an LLVM type"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    65
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    66
    ^ false
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    67
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    68
    "Created: / 08-08-2015 / 02:45:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    69
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    70
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    71
!Object methodsFor:'testing'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    72
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    73
isLLVMValue
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    74
    "Return true, if receiver represents an LLVM value"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    75
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    76
    ^ false
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    77
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    78
    "Created: / 08-08-2015 / 02:21:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    79
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    80
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
!SequenceableCollection methodsFor:'converting'!
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
asLLVMObjectArray
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    | array size | 
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
    size := self size.
16
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    87
    size == 0 ifTrue:[ 
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    88
        ^ nil
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    89
    ].
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    array := LLVMObjectArray new: size.
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    array replaceFrom: 1 count: size with: self.
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    ^array
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
    "Created: / 08-07-2015 / 22:58:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
16
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    95
    "Modified: / 03-08-2015 / 17:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    96
! !
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    97
12
f98e97fd02ef Package renamed from jv:libllvms to jv:llvm_s
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    98
!jv_llvm_s class methodsFor:'documentation'!
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
extensionsVersion_HG
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
    ^ '$Changeset: <not expanded> $'
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
! !