1*99e0aae7SDavid Rees# Copyright 2019 Google LLC 2*99e0aae7SDavid Rees# 3*99e0aae7SDavid Rees# Licensed under the Apache License, Version 2.0 (the "License"); 4*99e0aae7SDavid Rees# you may not use this file except in compliance with the License. 5*99e0aae7SDavid Rees# You may obtain a copy of the License at 6*99e0aae7SDavid Rees# 7*99e0aae7SDavid Rees# https://www.apache.org/licenses/LICENSE-2.0 8*99e0aae7SDavid Rees# 9*99e0aae7SDavid Rees# Unless required by applicable law or agreed to in writing, software 10*99e0aae7SDavid Rees# distributed under the License is distributed on an "AS IS" BASIS, 11*99e0aae7SDavid Rees# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*99e0aae7SDavid Rees# See the License for the specific language governing permissions and 13*99e0aae7SDavid Rees# limitations under the License. 14*99e0aae7SDavid Rees 15*99e0aae7SDavid Rees-- This is the Emboss Prelude. 16*99e0aae7SDavid Rees-- 17*99e0aae7SDavid Rees-- This is a special file whose names are imported into (and therefore usable 18*99e0aae7SDavid Rees-- in) every Emboss module. The IR for the Prelude module is included in every 19*99e0aae7SDavid Rees-- Emboss IR as the second element of the `module` list. 20*99e0aae7SDavid Rees 21*99e0aae7SDavid Rees# This namespace needs to match the namespace in emboss_prelude.h. 22*99e0aae7SDavid Rees# TODO(bolms): Move back-end-specific declarations to a separate file. 23*99e0aae7SDavid Rees[(cpp) namespace: "emboss::prelude"] 24*99e0aae7SDavid Rees 25*99e0aae7SDavid Rees 26*99e0aae7SDavid Reesexternal UInt: 27*99e0aae7SDavid Rees -- UInt is an automatically-sized unsigned integer. 28*99e0aae7SDavid Rees [static_requirements: $is_statically_sized && 1 <= $static_size_in_bits <= 64] 29*99e0aae7SDavid Rees [is_integer: true] 30*99e0aae7SDavid Rees [addressable_unit_size: 1] 31*99e0aae7SDavid Rees 32*99e0aae7SDavid Rees 33*99e0aae7SDavid Reesexternal Int: 34*99e0aae7SDavid Rees -- Int is an automatically-sized signed 2's-complement integer. 35*99e0aae7SDavid Rees [static_requirements: $is_statically_sized && 1 <= $static_size_in_bits <= 64] 36*99e0aae7SDavid Rees [is_integer: true] 37*99e0aae7SDavid Rees [addressable_unit_size: 1] 38*99e0aae7SDavid Rees 39*99e0aae7SDavid Rees 40*99e0aae7SDavid Reesexternal Bcd: 41*99e0aae7SDavid Rees -- `Bcd` is an automatically-sized unsigned integer stored in Binary-Coded 42*99e0aae7SDavid Rees -- Decimal (BCD) format. https://en.wikipedia.org/wiki/Binary-coded_decimal 43*99e0aae7SDavid Rees -- 44*99e0aae7SDavid Rees -- `Bcd` can be used in `bits` constructs. If its size is not a multiple of 45*99e0aae7SDavid Rees -- 4 bits, the value will be padded out to a multiple of 4 bits using 0s, and 46*99e0aae7SDavid Rees -- then the resulting bit pattern will be treated as BCD. Thus, a 7-bit `Bcd` 47*99e0aae7SDavid Rees -- will have a range of 0..79, a 10-bit `Bcd` will have a range of 0..399, and 48*99e0aae7SDavid Rees -- so on. 49*99e0aae7SDavid Rees [static_requirements: $is_statically_sized && 1 <= $static_size_in_bits <= 64] 50*99e0aae7SDavid Rees [is_integer: true] 51*99e0aae7SDavid Rees [addressable_unit_size: 1] 52*99e0aae7SDavid Rees 53*99e0aae7SDavid Rees 54*99e0aae7SDavid Reesexternal Flag: 55*99e0aae7SDavid Rees -- `Flag` is a boolean value, with `0` meaning `false` and `1` meaning `true`. 56*99e0aae7SDavid Rees [static_requirements: $is_statically_sized && $static_size_in_bits == 1] 57*99e0aae7SDavid Rees [fixed_size_in_bits: 1] 58*99e0aae7SDavid Rees # Flags are not integers; if a user wants a 1-bit integer, they should use a 59*99e0aae7SDavid Rees # 1-bit UInt. 60*99e0aae7SDavid Rees [is_integer: false] 61*99e0aae7SDavid Rees [addressable_unit_size: 1] 62*99e0aae7SDavid Rees 63*99e0aae7SDavid Rees 64*99e0aae7SDavid Reesexternal Float: 65*99e0aae7SDavid Rees -- `Float` is a number in an IEEE 754 binaryNN format. 66*99e0aae7SDavid Rees [static_requirements: $is_statically_sized && ($static_size_in_bits == 32 || $static_size_in_bits == 64)] 67*99e0aae7SDavid Rees [is_integer: false] 68*99e0aae7SDavid Rees [addressable_unit_size: 1] 69*99e0aae7SDavid Rees 70*99e0aae7SDavid Rees 71*99e0aae7SDavid Rees# TODO(bolms): Add Fixed-point. 72