Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[SPARC][Driver] Add -m(no-)v8plus flags handling #98713
[SPARC][Driver] Add -m(no-)v8plus flags handling #98713
Changes from 1 commit
ea6720f
d65ee3a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
We usually know whether a feature is default on or off.
If it is default off, the driver only passes
+xxx
, but suppresses-xxx
.Are both
+v9
and-v9
needed here?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.
It is off by default, but we also want it to override features enabled implicitly by
-mcpu
flags.For example if I pass
-mcpu=v9 -mno-v8plus
then I want the compilation to be done withv9
turned off.So I think it is needed... unless there's other ways to do this?
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.
This is quite confusing.
-m[no]-v8plus
is an environment option, similar to X86's-mx32
, but imposes more restrictions.-mcpu=v9 -mno-v8plus
should be equivalent to just-mcpu=v9
because 64-bit environment is the default for 64-bit ISA.-mv8plus
enables 32-bit environment and therefore should restrict the compiler from using the whole set of V9 features. That is, I would expect it to disable something rather than to enablev9
, which should already be set by-mcpu=v9
.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.
Either way, the order of
-mv8plus
relative to-mcpu
shouldn't matter (one sets the environment, the other sets the ISA).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.
It is true that those flags primarily control the target environment, however, on GCC,
-m[no-]v8plus
also implies that V9 instructions are available (or not, in case of-mno-v8plus
) (e.g when multiplying 64-bit numbers: https://godbolt.org/z/5zdWez6qz).Also, unlike
-mx32
,-m[no-]v8plus
is intended for use with 32-bit target (-m32
); again, with GCC,-mv8plus
raises an error with-m64
, and-mno-v8plus
is ignored (i.e it still generates 64-bit instructions) (https://godbolt.org/z/PcfMcT8cf).It would be possible to define the flags such that
-m[no-]v8plus
do not touch the V9 feature bit, but I feel like that would defeat the purpose of V8+ environment (that is, to let 32-bit code use some 64-bit V9 instructions).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.
Well, no. Not exactly. Whether or not V9 instructions are available is determined strictly by
-mcpu=v9
(which is the default). In both cases by the first godbolt link instructions are V9 instructions and operate on 64-bit registers.The thing is, you can't use the upper half of these registers reliably, which makes instructions such as MULX useless. There are, however, other instructions introduced in V9 that are usable -- 32-bit atomics for instance.
Also note that
-mno-v8plus
is the default and passing it explicitly won't change the behavior (unless you specified-mv8plus
prior to it).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.
Ah, I see.
In that case, would making these a no-op flag okay for now? As far as I understand it that would still be a compliant implementation, no? Codegen, etc. changes will happen in future patches but I can amend this one to include a placeholder
v8plus
feature bit in the backend.What do you think about it?
(Some background: I am currently only looking to include this in clang because Linux passes
-mv8plus
when building 32-bit objects since some of its inline asm uses 64-bit registers, but otherwise it doesn't care if compiler-generated code uses them or not)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.
AFAIK it is an ABI affecting flag, although I don't know if it changes anything except for ELF header's e_machine field compared to 32-bit V8/V9. It can't safely be ignored if we claim support for V8+. If we don't, and V8+ is otherwise compatible with 32-bit ABI, I think ignoring it and generating instructions should be fine, probably with a warning.
I have little experience in target feature bits. It could be helpful to have a draft that adds some V8+ support to the backend and the corresponding feature bits.
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.
AFAICT the main ABI change is widening the G and O registers to 64-bits, which is compatible with legacy ABI:
save
(which will result in the values being rotated - and truncated - into the I registers), so 64-bit arguments need to be split into 2x32-bit pair, just as in legacy ABI; andrestore
, so the caller will receive 64-bit returns as 2x32-bit pairs, just as in legacy ABI.Backend bits are in #101367 (incl. ELF e_machine type setting), that should be merged first before this PR.