-
Notifications
You must be signed in to change notification settings - Fork 289
Re-organize intrinsic-test
to enable seamless addition of behaviour testing for more architectures
#1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-organize intrinsic-test
to enable seamless addition of behaviour testing for more architectures
#1758
Conversation
9900e81
to
546554d
Compare
The module should be called |
@JamieCunliffe feel free to have a look at this since you are the original author of intrinsic-test. This is part of a GSoC project to extend intrinsic-test to other architectures. |
5dce230
to
7ff8497
Compare
Are we using the |
a12b4a4
to
ff10311
Compare
|
6e8851b
to
a2ce02c
Compare
intrinsic-test
to enable seamless addition of behaviour testing for more architecturesintrinsic-test
to enable seamless addition of behaviour testing for more architectures
intrinsic-test
to enable seamless addition of behaviour testing for more architecturesintrinsic-test
to enable seamless addition of behaviour testing for more architectures
df2c75d
to
5d360a0
Compare
5d360a0
to
66a88fe
Compare
Okay, I'm more or less done with resolving minor issues now. |
pub fn write_rust_testfiles<T: IntrinsicTypeDefinition>( | ||
intrinsics: Vec<&dyn IntrinsicDefinition<T>>, | ||
rust_target: &str, | ||
notice: &str, | ||
definitions: &str, | ||
cfg: &str, | ||
) -> Vec<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change I made in the last commit was adding the "definitions" argument so that we could accommodate the f16 formatting related changes made in this commit
|
||
/// Defines the basic structure of achitecture-specific derivatives | ||
/// of IntrinsicType. | ||
#[macro_export] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using this macro, consider just implementing Deref
so that methods forward to the inner type. This also removes the need for the BaseIntrinsicTypeDefinition
trait, they can just be inherent methods on IntrinsicType
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thank you so much!
I was able to remove a lot of redundant code.
/// rust debug output format for the return type. The generated line assumes | ||
/// there is an int i in scope which is the current pass number. | ||
fn print_result_c(&self, _indentation: Indentation, _additional: &str) -> String { | ||
unimplemented!("Architectures need to implement print_result_c!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this have a default implementation if it is mandatory?
intrinsic_call = self.name(), | ||
args = self.arguments().as_call_param_c(), | ||
print_result = self.print_result_c(body_indentation, additional) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this part of the trait when it's identical to the ARM implementation? If this is intended to be the same in all architectures then it doesn't need to be in the trait. Or at least make the ARM backend us the default implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I think all the methods below and including this one should just be removed from the trait: there isn't really any reason for target-specific customization of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought having the common functionality in the trait would make it more ergonomic.
I overlooked the part where the specific functionality won't need to be adjusted for different architectures.
I'll update this, thank you for pointing out.
/// Determines the load function for this type. | ||
/// can be implemented in an `impl` block | ||
fn get_load_function(&self, _language: Language) -> String { | ||
unimplemented!("Different architectures must implement get_load_function!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why provide a default implementation if it must be implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, I thought it might help with debugging in case the function isn't implemented downstream.
I'll remove this.
constraints | ||
}; | ||
|
||
let indentation2 = indentation.nested(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The f16 handling in the ARM-specific code should actually be moved into the common code: f16 support is also going to be need for some x86 intrinsics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
generate_c_program( | ||
notices, | ||
header_files, | ||
"aarch64", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"aarch64"
in the common code.
1. Removed default implementation of traits that are compulsorily implemented 2. Replaced BaseIntrinsicTypeDefinition with Deref<Target = IntrinsicType>
07a0221
to
50fde10
Compare
modifications) outside the IntrinsicDefinition trait
053c90a
to
dfacf9d
Compare
Over the last 4 commits, I've:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice first step to me, thanks!
Thank you so much @adamgemmell @Amanieu ! There was quite a lot of learning for me on the architecture design front. |
Updates so far
arm
module, exposing only atest
function atsrc/main.rs
SupportedArchitectureTest
trait that has been implemented forarm
and should be implemented for other architectures too. Allows us to expose functionality like building C/Rust test files and comparing outputs.common
module for reuse by other architectures too.match
block for selection of architectures using thetarget
CLI variable.Reasoning
Intrinsic
type may be specific to architectures, hence the implementation of a trait helps us to abstract the usage of such data types within the architecture-specific moduleNew architecture of
intrinsic-test