This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Pass MCSubtargetInfo to print methods.
ClosedPublic

Authored by apazos on Dec 21 2017, 10:37 AM.

Details

Summary

This change allows checking for ISA extensions in print methods.

Diff Detail

Repository
rL LLVM

Event Timeline

apazos created this revision.Dec 21 2017, 10:37 AM
asb accepted this revision.Jan 4 2018, 2:51 AM

Looking at the comment for PassSubtarget in Target.td it seems like this is something we should enable. Is there an observable bug in the current backend that can be fixed thanks to this?

This revision is now accepted and ready to land.Jan 4 2018, 2:51 AM
asb added a subscriber: niosHD.Jan 4 2018, 9:31 AM

@niosHD suggested there might be an observable issue with the instalias for floating point CSRs

niosHD added a comment.Jan 4 2018, 9:59 AM

Ignoring the predicates currently leads to the problem that aliases get printed although the corresponding extension is not enabled.

For example, the following snippet disassembles csrrs to frcsr although the f extension is not enabled. Assembling on the other hand works as expected, i.e., frcsr is rejected when the f extension is disabled.

% cat csrrs.S
csrrs t0, 3, zero

mwerner@t440smw ~/tmp [2018-01-04 18:51:33]
% llvm-mc -filetype=obj -triple riscv64 < csrrs.S  | llvm-objdump -d -

<stdin>:        file format ELF64-riscv

Disassembly of section .text:
.text:
       0:       f3 22 30 00     frcsr   t0

It would be great if we can fix this flaw by enabling PassSubtarget.

apazos added a comment.Jan 8 2018, 2:44 PM

Hi Mario, thanks for the pointing out this alias test case.
I confirm that the patch fixes this case.

llvm-mc -triple riscv64 -filetype=obj < csrrs.S |llvm-objdump -d -

<stdin>: file format ELF64-riscv

Disassembly of section .text:
.text:

0:       f3 22 30 00     csrr    t0, 3
niosHD accepted this revision.Jan 11 2018, 8:30 AM

Great, thank you Ana for confirming that this patch fixes the problem.

Do you plan to add the test to the test suite or should I submit a patch after this one has landed?

apazos updated this revision to Diff 129562.Jan 11 2018, 6:14 PM

Rebased and added test case

Hi Mario, I added the CSR aliases test.

This revision was automatically updated to reflect the committed changes.