Ejemplo n.º 1
0
# RUN: %PYTHON %s | npcomp-opt -split-input-file | FileCheck %s --dump-input=fail

import collections
import math
from npcomp.compiler import test_config

import_global = test_config.create_import_dump_decorator()


# CHECK-LABEL: func @module_constant
@import_global
def module_constant():
    # CHECK: constant 3.1415926535897931 : f64
    return math.pi


Sub = collections.namedtuple("Sub", "term")
Record = collections.namedtuple("Record", "fielda,fieldb,inner")
record = Record(5, 25, Sub(6))


# CHECK-LABEL: func @namedtuple_attributes
@import_global
def namedtuple_attributes():
    # CHECK: constant 6
    # CHECK: constant 25
    return record.inner.term - record.fieldb
Ejemplo n.º 2
0
# RUN: %PYTHON %s | npcomp-opt -split-input-file | FileCheck %s --dump-input=fail

# Subset of constant tests which verify against a GenericTarget32.

from npcomp.compiler import test_config
from npcomp.compiler.target import *

import_global = test_config.create_import_dump_decorator(
    target_factory=GenericTarget32)


# CHECK-LABEL: func @integer_constants
@import_global
def integer_constants():
    # CHECK: %[[A:.*]] = constant 100 : i32
    a = 100
    return a


# CHECK-LABEL: func @float_constants
@import_global
def float_constants():
    # CHECK: %[[A:.*]] = constant 2.200000e+00 : f32
    a = 2.2
    return a