Commit Graph

9103 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
c712ddc776 Handle value type names in the lexer. 2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
1228abca29 Begin lexer implementation.
Add a lexer module which implements the lexical analysis of .cton files.
2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
ab74770ffe Begin lexer implementation.
Add a lexer module which implements the lexical analysis of .cton files.
2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
bbeafde243 Type::by() returns an Optional<Type>.
Don't use assertions to enforce the limits on SIMD lanes in a type, Type is too
fundamental for that. Instead, the Vector-forming by() method returns an
Optional<Type>, and None if the requested SIMD vector is not valid.

Same for Type::half_vector().
2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
9e00ce5081 Type::by() returns an Optional<Type>.
Don't use assertions to enforce the limits on SIMD lanes in a type, Type is too
fundamental for that. Instead, the Vector-forming by() method returns an
Optional<Type>, and None if the requested SIMD vector is not valid.

Same for Type::half_vector().
2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
c0f77f35c7 Add function signatures.
Describe function argument and return value types along with flags for passing
values in an ABI-compliant way.
2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
04d3b10564 Add function signatures.
Describe function argument and return value types along with flags for passing
values in an ABI-compliant way.
2016-04-27 17:07:54 -07:00
Jakob Stoklund Olesen
58f70ef12d Implement FromStr for Imm64, Ieee32, Ieee64.
These are bitwise exact conversions from string to immediates, implementing the
inverse of the Display trait.

Only accept hexadecimal floating point numbers to avoid issues with rounding
when converting decimal numbers to binary.
2016-04-27 17:07:46 -07:00
Jakob Stoklund Olesen
6a1f74125f Implement FromStr for Imm64, Ieee32, Ieee64.
These are bitwise exact conversions from string to immediates, implementing the
inverse of the Display trait.

Only accept hexadecimal floating point numbers to avoid issues with rounding
when converting decimal numbers to binary.
2016-04-27 17:07:46 -07:00
Jakob Stoklund Olesen
71f8fe1cb1 Migrate to readthedocs.io 2016-04-27 17:05:02 -07:00
Jakob Stoklund Olesen
f1d43652ad Migrate to readthedocs.io 2016-04-27 17:05:02 -07:00
Jakob Stoklund Olesen
9a6f79a9ba Add some scaffolding for building more crates.
The src/tools directory contains the cretonne-tools crate which will build
binaries for testing cretonne.

The src/libctonfile directory contains the ctonfile library crate which
provides reading and writing of .cton files.
2016-04-08 12:55:29 -07:00
Jakob Stoklund Olesen
4f40a2ae79 Add some scaffolding for building more crates.
The src/tools directory contains the cretonne-tools crate which will build
binaries for testing cretonne.

The src/libctonfile directory contains the ctonfile library crate which
provides reading and writing of .cton files.
2016-04-08 12:55:29 -07:00
Jakob Stoklund Olesen
661ac9e7ad Implement std::str::FromStr for matching opcodes.
Replace the home-grown from_str function.
2016-04-08 11:06:33 -07:00
Jakob Stoklund Olesen
49ae98a1e9 Implement std::str::FromStr for matching opcodes.
Replace the home-grown from_str function.
2016-04-08 11:06:33 -07:00
Jakob Stoklund Olesen
53c878f4e1 Typo. 2016-04-08 10:31:14 -07:00
Jakob Stoklund Olesen
66778dc23c Typo. 2016-04-08 10:31:14 -07:00
Jakob Stoklund Olesen
1b7d5d849f Generate a constant hash table for recognizing opcodes.
Use a simple quadratically probed, open addressed hash table. We could use a
parfect hash function, but it would take longer to compute in Python, and this
is not in the critical path performancewise.
2016-04-07 20:24:21 -07:00
Jakob Stoklund Olesen
24e0828d20 Generate a constant hash table for recognizing opcodes.
Use a simple quadratically probed, open addressed hash table. We could use a
parfect hash function, but it would take longer to compute in Python, and this
is not in the critical path performancewise.
2016-04-07 20:24:21 -07:00
Jakob Stoklund Olesen
85248a4b18 Generate an opcode_name() function.
This function returning a &'static str is more primitive that the Display
implementation. It allows the opcode strings to be reused by the parser.
2016-04-07 13:49:35 -07:00
Jakob Stoklund Olesen
3dcd2f8e58 Generate an opcode_name() function.
This function returning a &'static str is more primitive that the Display
implementation. It allows the opcode strings to be reused by the parser.
2016-04-07 13:49:35 -07:00
Jakob Stoklund Olesen
b0c0dd1b9f Add repr.rs module containing the representation of functions.
A function owns instructions and extended basic blocks. References to these
entities are implemented as opaque structs indexing into the functions internal
tables. This avoids fighting Rust's ownership checking and it also makes
references 4 bytes on all platforms.

SSA values are identified similarly, but with an optimization for the first
value produced by an instruction. Very few instructions will produce more than
one value, and there is an extended value table for those.
2016-04-07 11:53:37 -07:00
Jakob Stoklund Olesen
3a570e8b21 Add repr.rs module containing the representation of functions.
A function owns instructions and extended basic blocks. References to these
entities are implemented as opaque structs indexing into the functions internal
tables. This avoids fighting Rust's ownership checking and it also makes
references 4 bytes on all platforms.

SSA values are identified similarly, but with an optimization for the first
value produced by an instruction. Very few instructions will produce more than
one value, and there is an extended value table for those.
2016-04-07 11:53:37 -07:00
Jakob Stoklund Olesen
ee09a39aef Include generated Opcode enum in the immediates module.
Generate nice doc comments for the Opcode enum variants that 'cargo doc'
will pick up.

Include a `Display` trait implementation that prints the lower
snake-case version of the opcode name.
2016-04-06 14:55:21 -07:00
Jakob Stoklund Olesen
d650d551a0 Include generated Opcode enum in the immediates module.
Generate nice doc comments for the Opcode enum variants that 'cargo doc'
will pick up.

Include a `Display` trait implementation that prints the lower
snake-case version of the opcode name.
2016-04-06 14:55:21 -07:00
Jakob Stoklund Olesen
eba396546a Begin source generation.
Start out easy by emiting an opcodes.rs file containing an opcode enumeration.
2016-04-06 12:22:56 -07:00
Jakob Stoklund Olesen
15f39c776c Begin source generation.
Start out easy by emiting an opcodes.rs file containing an opcode enumeration.
2016-04-06 12:22:56 -07:00
Jakob Stoklund Olesen
6e2e7bfb73 Add a RISC-V target.
Flesh out the directory structure for defining target instruction set
architectures. Use RISC-V as a startgin point because it is so simple.
2016-04-06 12:00:35 -07:00
Jakob Stoklund Olesen
7bf4570ba1 Add a RISC-V target.
Flesh out the directory structure for defining target instruction set
architectures. Use RISC-V as a startgin point because it is so simple.
2016-04-06 12:00:35 -07:00
Jakob Stoklund Olesen
5388f68437 Give instructions a CamelCase name.
This will be used as the instruction name in Rust code. By making this a
property of the instruction, it can be changed by the user if desired.
2016-04-05 15:29:07 -07:00
Jakob Stoklund Olesen
936d6e523a Give instructions a CamelCase name.
This will be used as the instruction name in Rust code. By making this a
property of the instruction, it can be changed by the user if desired.
2016-04-05 15:29:07 -07:00
Jakob Stoklund Olesen
99b1251b35 Collect all instructions into instruction groups. 2016-04-05 14:42:41 -07:00
Jakob Stoklund Olesen
6f083a310a Collect all instructions into instruction groups. 2016-04-05 14:42:41 -07:00
Jakob Stoklund Olesen
0b8db43bbe Add scaffolding for a Python build script.
Hook up a Cargo build script that runs a Python script in the meta directory.
2016-04-05 13:36:04 -07:00
Jakob Stoklund Olesen
d32d78d16c Add scaffolding for a Python build script.
Hook up a Cargo build script that runs a Python script in the meta directory.
2016-04-05 13:36:04 -07:00
Jakob Stoklund Olesen
807b718358 Add an autohtml target to docs/Makefile.
This runs the convenient sphinx-autobuild web server for docs development.
2016-04-05 11:11:53 -07:00
Jakob Stoklund Olesen
d197f8a104 Add an autohtml target to docs/Makefile.
This runs the convenient sphinx-autobuild web server for docs development.
2016-04-05 11:11:53 -07:00
Jakob Stoklund Olesen
f72f47aece Replace bool with b1, b8, b16, ...
The b1 type is an abstract boolean value. The others are concrete
representations.
2016-04-05 10:45:00 -07:00
Jakob Stoklund Olesen
043bb1aba5 Replace bool with b1, b8, b16, ...
The b1 type is an abstract boolean value. The others are concrete
representations.
2016-04-05 10:45:00 -07:00
Jakob Stoklund Olesen
4b265c2ee3 Display quiet NaNs as 'NaN'.
This is recommended by IEEE 754-2008.

We still distinguish signaling NaNs with 'sNaN'.
2016-04-05 10:27:18 -07:00
Jakob Stoklund Olesen
79e765a183 Display quiet NaNs as 'NaN'.
This is recommended by IEEE 754-2008.

We still distinguish signaling NaNs with 'sNaN'.
2016-04-05 10:27:18 -07:00
Jakob Stoklund Olesen
524eb77185 Implement IEEE immediates for binary32 and binary64.
Clarify the textual encoding of floating point numbers.

Don't allow decimal floating point since conversion to/from binary can produce
rounding problems on some (buggy) systems.
2016-04-01 14:40:15 -07:00
Jakob Stoklund Olesen
5f706b0a1f Implement IEEE immediates for binary32 and binary64.
Clarify the textual encoding of floating point numbers.

Don't allow decimal floating point since conversion to/from binary can produce
rounding problems on some (buggy) systems.
2016-04-01 14:40:15 -07:00
Jakob Stoklund Olesen
ad07f67331 Move constant instructions into meta.
Add new immediate types for floating point and vector immediates.
Use new immediates to define the constant value instructions in meta.

Split the fconst instruction into two: f32const and f64const. This prevents
confusion about the interpretation of 64 immediate bits when generating an f32
constant.

Add an immvector ImmediateType. This immediate type is variable length, and
provides all the bits of a SIMD vector directly.
2016-04-01 10:08:57 -07:00
Jakob Stoklund Olesen
e5305c249b Move constant instructions into meta.
Add new immediate types for floating point and vector immediates.
Use new immediates to define the constant value instructions in meta.

Split the fconst instruction into two: f32const and f64const. This prevents
confusion about the interpretation of 64 immediate bits when generating an f32
constant.

Add an immvector ImmediateType. This immediate type is variable length, and
provides all the bits of a SIMD vector directly.
2016-04-01 10:08:57 -07:00
Jakob Stoklund Olesen
a2db4b680e Move instruction definitions into meta.
Use the meta language to define instructions, just insert 'autoinst' references
in langref.
2016-04-01 10:08:57 -07:00
Jakob Stoklund Olesen
c3233fb332 Move instruction definitions into meta.
Use the meta language to define instructions, just insert 'autoinst' references
in langref.
2016-04-01 10:08:57 -07:00
Jakob Olesen
20183554a4 Add Instruction and Operand classes to the meta language. 2016-04-01 10:08:57 -07:00
Jakob Olesen
a76a0da826 Add Instruction and Operand classes to the meta language. 2016-04-01 10:08:57 -07:00
Jakob Stoklund Olesen
de12bc0f1a Implement Imm64 in an 'immediates.rs' module.
Format larger immediates as hexadecimal with a multiple of 4 digits and '_'
group separators.
2016-04-01 10:08:01 -07:00