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