This is an archive of the discontinued LLVM Phabricator instance.

[mips] Add assembler support for .set arch=x directive.
ClosedPublic

Authored by tomatabacu on Aug 13 2014, 8:01 AM.

Details

Summary

This directive is similar to ".set mipsX".
It is used to change the CPU target of the assembler, enabling it to accept instructions for a specific CPU.

This patch only implements the r4000 CPU (which is treated internally as generic mips3) and the generic ISAs.

Contains work done by Matheus Almeida.

Diff Detail

Event Timeline

tomatabacu updated this revision to Diff 12450.Aug 13 2014, 8:01 AM
tomatabacu retitled this revision from to [mips] Add assembler support for .set arch=x directive..
tomatabacu updated this object.
tomatabacu edited the test plan for this revision. (Show Details)
tomatabacu added a reviewer: dsanders.
tomatabacu updated this revision to Diff 12455.Aug 13 2014, 8:14 AM

Improved a parsing error message.
Added a newline at the end of set-arch.s.

dsanders added inline comments.Aug 14 2014, 1:46 AM
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
344–357

Why not true/false instead of 1/0?

2616–2624

A couple things here. The first is that the emitDirectiveSetArch() should be given the same string as was originally parsed. This will stop '.set arch=r4000' mutating into '.set arch=mips3'. The second is that we can detect unsupported strings at the same time we convert them to feature names using something like:

ArchFeatureName = StringSwitch<std::string>(Arch)
                                  .Case("mips1", "mips1")
                                  ...
                                  .Case("mips64r6", "mips64r6")
                                  .Case("r4000", "mips3")
                                  .Default("");
if (ArchFeatureName.empty())
  return reportParseError(...);
selectArch(ArchFeatureName);
getTargetStreamer().emitDirectiveSetArch(Arch);
test/MC/Mips/set-arch.s
32

This one should be '.set arch=r4000'.

tomatabacu updated this object.Aug 14 2014, 2:44 AM
tomatabacu updated this revision to Diff 12499.EditedAug 14 2014, 5:33 AM

Addressed comments, rebased and ran clang-format.
Also (basically) inlined isSupportedArch.

dsanders accepted this revision.Aug 19 2014, 5:18 AM
dsanders edited edge metadata.

LGTM

This revision is now accepted and ready to land.Aug 19 2014, 5:18 AM
tomatabacu updated this revision to Diff 12661.EditedAug 19 2014, 6:06 AM
tomatabacu edited edge metadata.

Improve test and rebased.

tomatabacu closed this revision.Aug 19 2014, 7:32 AM