[build] Use the Rust-generated types files in place of the Python one;
This commit is contained in:
committed by
Dan Gohman
parent
8d7538049c
commit
17e88ed1c5
@@ -80,7 +80,7 @@ fn main() {
|
|||||||
// Now that the Python build process is complete, generate files that are
|
// Now that the Python build process is complete, generate files that are
|
||||||
// emitted by the `meta` crate.
|
// emitted by the `meta` crate.
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
if let Err(err) = meta::gen_types::generate("new_types.rs", &out_dir) {
|
if let Err(err) = meta::gen_types::generate("types.rs", &out_dir) {
|
||||||
eprintln!("Error: {}", err);
|
eprintln!("Error: {}", err);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import argparse
|
import argparse
|
||||||
import isa
|
import isa
|
||||||
import gen_types
|
|
||||||
import gen_instr
|
import gen_instr
|
||||||
import gen_settings
|
import gen_settings
|
||||||
import gen_build_deps
|
import gen_build_deps
|
||||||
@@ -26,7 +25,6 @@ def main():
|
|||||||
|
|
||||||
isas = isa.all_isas()
|
isas = isa.all_isas()
|
||||||
|
|
||||||
gen_types.generate(out_dir)
|
|
||||||
gen_instr.generate(isas, out_dir)
|
gen_instr.generate(isas, out_dir)
|
||||||
gen_settings.generate(isas, out_dir)
|
gen_settings.generate(isas, out_dir)
|
||||||
gen_encoding.generate(isas, out_dir)
|
gen_encoding.generate(isas, out_dir)
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
"""
|
|
||||||
Generate sources with type info.
|
|
||||||
|
|
||||||
This generates a `types.rs` file which is included in
|
|
||||||
`lib/codegen/ir/types.rs`. The file provides constant definitions for the most
|
|
||||||
commonly used types, including all of the scalar types.
|
|
||||||
|
|
||||||
This ensures that Python and Rust use the same type numbering.
|
|
||||||
"""
|
|
||||||
from __future__ import absolute_import
|
|
||||||
import srcgen
|
|
||||||
from cdsl.types import ValueType
|
|
||||||
import base.types # noqa
|
|
||||||
|
|
||||||
try:
|
|
||||||
from typing import Iterable # noqa
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def emit_type(ty, fmt):
|
|
||||||
# type: (ValueType, srcgen.Formatter) -> None
|
|
||||||
"""
|
|
||||||
Emit a constant definition of a single value type.
|
|
||||||
"""
|
|
||||||
name = ty.name.upper()
|
|
||||||
fmt.doc_comment(ty.__doc__)
|
|
||||||
fmt.line(
|
|
||||||
'pub const {}: Type = Type({:#x});'
|
|
||||||
.format(name, ty.number))
|
|
||||||
fmt.line()
|
|
||||||
|
|
||||||
|
|
||||||
def emit_vectors(bits, fmt):
|
|
||||||
# type: (int, srcgen.Formatter) -> None
|
|
||||||
"""
|
|
||||||
Emit definition for all vector types with `bits` total size.
|
|
||||||
"""
|
|
||||||
size = bits // 8
|
|
||||||
for ty in ValueType.all_lane_types:
|
|
||||||
mb = ty.membytes
|
|
||||||
if mb == 0 or mb >= size:
|
|
||||||
continue
|
|
||||||
emit_type(ty.by(size // mb), fmt)
|
|
||||||
|
|
||||||
|
|
||||||
def emit_types(fmt):
|
|
||||||
# type: (srcgen.Formatter) -> None
|
|
||||||
for spec in ValueType.all_special_types:
|
|
||||||
emit_type(spec, fmt)
|
|
||||||
for ty in ValueType.all_lane_types:
|
|
||||||
emit_type(ty, fmt)
|
|
||||||
# Emit vector definitions for common SIMD sizes.
|
|
||||||
emit_vectors(64, fmt)
|
|
||||||
emit_vectors(128, fmt)
|
|
||||||
emit_vectors(256, fmt)
|
|
||||||
emit_vectors(512, fmt)
|
|
||||||
|
|
||||||
|
|
||||||
def generate(out_dir):
|
|
||||||
# type: (str) -> None
|
|
||||||
fmt = srcgen.Formatter()
|
|
||||||
emit_types(fmt)
|
|
||||||
fmt.update_file('types.rs', out_dir)
|
|
||||||
@@ -30,7 +30,7 @@ const LANE_BASE: u8 = 0x70;
|
|||||||
/// Start of the 2-lane vector types.
|
/// Start of the 2-lane vector types.
|
||||||
const VECTOR_BASE: u8 = LANE_BASE + 16;
|
const VECTOR_BASE: u8 = LANE_BASE + 16;
|
||||||
|
|
||||||
// Include code generated by `lib/codegen/meta-python/gen_types.py`. This file contains constant
|
// Include code generated by `lib/codegen/meta/gen_types.rs`. This file contains constant
|
||||||
// definitions for all the scalar types as well as common vector types for 64, 128, 256, and
|
// definitions for all the scalar types as well as common vector types for 64, 128, 256, and
|
||||||
// 512-bit SIMD vectors.
|
// 512-bit SIMD vectors.
|
||||||
include!(concat!(env!("OUT_DIR"), "/types.rs"));
|
include!(concat!(env!("OUT_DIR"), "/types.rs"));
|
||||||
|
|||||||
Reference in New Issue
Block a user