LLVMModuleTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 17 Sep 2015 17:17:56 +0100
changeset 42 23ae490859cd
parent 35 fd459b38f324
permissions -rw-r--r--
Fixed LLVMExamples>>example7_factorial_with_debug_info Pass DIFile instead of DICompileUnit to #createTypeFunctionIn:parameterTypes: Fixed #createParameterVariable: - parameters are numbered starting with 1.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
    Copyright (C) 2015-now Jan Vrany
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
    This code is not an open-source (yet). You may use this code
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
    for your own experiments and projects, given that:
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
    * all modification to the code will be sent to the
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
      original author for inclusion in future releases
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
    * this is not used in any commercial software
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
    This license is provisional and may (will) change in
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
    a future.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
"{ Package: 'jv:llvm_s' }"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
"{ NameSpace: Smalltalk }"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
TestCase subclass:#LLVMModuleTests
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	instanceVariableNames:''
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
	classVariableNames:''
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	poolDictionaries:''
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
	category:'LLVM-S-Core-Tests'
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
!
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
!LLVMModuleTests class methodsFor:'documentation'!
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
copyright
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
    Copyright (C) 2015-now Jan Vrany
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
    This code is not an open-source (yet). You may use this code
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
    for your own experiments and projects, given that:
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
    * all modification to the code will be sent to the
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
      original author for inclusion in future releases
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
    * this is not used in any commercial software
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    This license is provisional and may (will) change in
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
    a future.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
! !
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
!LLVMModuleTests methodsFor:'tests'!
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
test_functions_01
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    | module function |
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    module := LLVMModule new.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
    module addFunctionNamed: 'xxx'  type: (LLVMType function: { LLVMType int8 } returning: LLVMType int8).
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    function := module getFunctionNamed: 'xxx'.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
    self assert: function notNil.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    self assert: function isLLVMFunction.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    "Created: / 03-09-2015 / 06:48:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
!
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
test_intrinsics_01
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
    | module intrinsic |
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
    module := LLVMModule new.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
    intrinsic := module getIntrinsicNamed: 'llvm.trap'.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
    self assert: intrinsic notNil.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
    self assert: intrinsic isLLVMFunction.
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
    "Created: / 02-09-2015 / 22:29:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
    "Modified: / 03-09-2015 / 06:31:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
! !
fd459b38f324 Added LLVMModule>>getFunctionNamed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70