File: value-references.rst

package info (click to toggle)
llvmlite 0.46.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,140 kB
  • sloc: python: 13,605; cpp: 3,192; makefile: 185; sh: 168
file content (224 lines) | stat: -rw-r--r-- 5,787 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
================
Value references
================

.. currentmodule:: llvmlite.binding

A value reference is a wrapper around an LLVM value for you to
inspect. You cannot create a value reference yourself. You get them
from methods of the :class:`ModuleRef` and :class:`ValueRef` classes.

Enumerations
------------

.. class:: Linkage

   The linkage types allowed for global values are:

   * .. data:: external
   * .. data:: available_externally
   * .. data:: linkonce_any
   * .. data:: linkonce_odr
   * .. data:: linkonce_odr_autohide
   * .. data:: weak_any
   * .. data:: weak_odr
   * .. data:: appending
   * .. data:: internal
   * .. data:: private
   * .. data:: dllimport
   * .. data:: dllexport
   * .. data:: external_weak
   * .. data:: ghost
   * .. data:: common
   * .. data:: linker_private
   * .. data:: linker_private_weak


.. class:: Visibility

   The visibility styles allowed for global values are:

   * .. data:: default
   * .. data:: hidden
   * .. data:: protected


.. class:: StorageClass

   The storage classes allowed for global values are:

   * .. data:: default
   * .. data:: dllimport
   * .. data:: dllexport


.. class:: ValueKind

   The value kinds allowed are:

   * .. data:: argument
   * .. data:: basic_block
   * .. data:: memory_use
   * .. data:: memory_def
   * .. data:: memory_phi
   * .. data:: function
   * .. data:: global_alias
   * .. data:: global_ifunc
   * .. data:: global_variable
   * .. data:: block_address
   * .. data:: constant_expr
   * .. data:: constant_array
   * .. data:: constant_struct
   * .. data:: constant_vector
   * .. data:: undef_value
   * .. data:: constant_aggregate_zero
   * .. data:: constant_data_array
   * .. data:: constant_data_vector
   * .. data:: constant_int
   * .. data:: constant_fp
   * .. data:: constant_pointer_null
   * .. data:: constant_token_none
   * .. data:: metadata_as_value
   * .. data:: inline_asm
   * .. data:: instruction
   * .. data:: poison_value


The ValueRef class
------------------

.. class:: ValueRef

   A wrapper around an LLVM value. The attributes available are:

   * .. attribute:: is_declaration

        * ``True``---The global value is a mere declaration.
        * ``False``---The global value is defined in the given 
          module.

   * .. attribute:: linkage

        The linkage type---a :class:`Linkage` instance---for 
        this value. This attribute can be set.

   * .. attribute:: module

        The module---a :class:`ModuleRef` instance---that this
        value is defined in.

   * .. attribute:: function

        The function---a :class:`ValueRef` instance---that this
        value is defined in.

   * .. attribute:: block

        The basic block---a :class:`ValueRef` instance---that this
        value is defined in.

   * .. attribute:: instruction

        The instruction---a :class:`ValueRef` instance---that this
        value is defined in.

   * .. attribute:: name

        This value's name, as a string. This attribute can be set.

   * .. attribute:: type

        This value's LLVM type as :class:`TypeRef` object.

   * .. attribute:: storage_class

        The storage 
        class---a :class:`StorageClass` instance---for 
        this value. This attribute can be set.

   * .. attribute:: visibility

        The visibility 
        style---a :class:`Visibility` instance---for 
        this value. This attribute can be set.

   * .. attribute:: value_kind

        The LLVM value kind---a :class:`ValueKind` instance---for
        this value.

   * .. attribute:: blocks

        An iterator over the basic blocks in this function.
        Each block is a :class:`ValueRef` instance.

   * .. attribute:: arguments

        An iterator over the arguments of this function.
        Each argument is a :class:`ValueRef` instance.

   * .. attribute:: instructions

        An iterator over the instructions in this basic block.
        Each instruction is a :class:`ValueRef` instance.

   * .. attribute:: incoming_blocks

        An iterator over the incoming blocks of a phi instruction.
        Each block is a :class:`ValueRef` instance.

   * .. attribute:: operands

        An iterator over the operands in this instruction.
        Each operand is a :class:`ValueRef` instance.

   * .. attribute:: opcode

        The instruction's opcode, as a string.

   * .. attribute:: attributes

        An iterator over the attributes in this value.
        Each attribute is a :class:`bytes` instance.
        Values that have attributes are: function, argument (and
        others for which attributes support has not been implemented)

   * .. attribute:: is_global

        The value is a global variable.

   * .. attribute:: is_function

        The value is a function.

   * .. attribute:: is_argument

        The value is a function's argument.

   * .. attribute:: is_block

        The value is a function's basic block.

   * .. attribute:: is_instruction

        The value is a basic block's instruction.

   * .. attribute:: is_operand

        The value is a instruction's operand.

   * .. attribute:: is_constant

        The value is a constant.

   * .. method:: get_constant_value(self, signed_int=False, round_fp=False)

        Return the constant value, either as a literal (for example, int
        or float) when supported, or as a string otherwise. Keyword arguments
        specify the preferences during conversion:

           * If ``signed_int`` is True and the constant is an integer, returns a
             signed integer.
           * If ``round_fp`` True and the constant is a floating point value,
             rounds the result upon accuracy loss (e.g., when querying an fp128
             value). By default, raises an exception on accuracy loss.