Skip to content

types

Classes:

Functions:

VariablesLLVM

Methods:

get_data_type

get_data_type(type_name: str) -> Type
Source code in src/irx/builders/llvmliteir/types.py
 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
def get_data_type(self, type_name: str) -> ir.types.Type:
    """
    title: Get data type.
    parameters:
      type_name:
        type: str
    returns:
      type: ir.types.Type
    """
    if type_name == "float32":
        return self.FLOAT_TYPE
    if type_name == "float16":
        return self.FLOAT16_TYPE
    if type_name in ("double", "float64"):
        return self.DOUBLE_TYPE
    if type_name == "boolean":
        return self.BOOLEAN_TYPE
    if type_name == "int8":
        return self.INT8_TYPE
    if type_name == "int16":
        return self.INT16_TYPE
    if type_name == "int32":
        return self.INT32_TYPE
    if type_name == "int64":
        return self.INT64_TYPE
    if type_name == "char":
        return self.INT8_TYPE
    if type_name in ("string", "stringascii"):
        return self.ASCII_STRING_TYPE
    if type_name == "utf8string":
        return self.UTF8_STRING_TYPE
    if type_name == "uint8":
        return self.UINT8_TYPE
    if type_name == "uint16":
        return self.UINT16_TYPE
    if type_name == "uint32":
        return self.UINT32_TYPE
    if type_name == "uint64":
        return self.UINT64_TYPE
    if type_name == "uint128":
        return self.UINT128_TYPE
    if type_name == "nonetype":
        return self.VOID_TYPE

    raise Exception(f"[EE]: Type name {type_name} not valid.")

is_fp_type

is_fp_type(type_: Type) -> bool
Source code in src/irx/builders/llvmliteir/types.py
18
19
20
21
22
23
24
25
26
27
28
29
30
def is_fp_type(type_: ir.Type) -> bool:
    """
    title: Is fp type.
    parameters:
      type_:
        type: ir.Type
    returns:
      type: bool
    """
    fp_types = [HalfType, FloatType, DoubleType]
    if FP128Type is not None:
        fp_types.append(FP128Type)
    return isinstance(type_, tuple(fp_types))

is_int_type

is_int_type(type_: Type) -> bool
Source code in src/irx/builders/llvmliteir/types.py
33
34
35
36
37
38
39
40
41
42
def is_int_type(type_: ir.Type) -> bool:
    """
    title: Is int type.
    parameters:
      type_:
        type: ir.Type
    returns:
      type: bool
    """
    return isinstance(type_, ir.IntType)