This is an archive of the discontinued LLVM Phabricator instance.

[mips] Set GCC-compatible MIPS asssembler options before inline asm blocks.
ClosedPublic

Authored by tomatabacu on Dec 12 2014, 6:26 AM.

Details

Summary

When generating MIPS assembly, LLVM always overrides the default assembler options by emitting the '.set noreorder', '.set nomacro' and '.set noat' directives,
while GCC uses the default options if an assembly-level function contains inline assembly code.

This becomes a problem when the code generated by LLVM is interleaved with inline assembly which assumes GCC-like assembler options (from Linux, for example).

This patch fixes these conflicts by setting the appropriate assembler options at the beginning of an inline asm block and popping them at the end.

Diff Detail

Event Timeline

tomatabacu updated this revision to Diff 17227.Dec 12 2014, 6:26 AM
tomatabacu retitled this revision from to [mips] Set GCC-compatible MIPS asssembler options before inline asm blocks..
tomatabacu updated this object.
tomatabacu edited the test plan for this revision. (Show Details)
tomatabacu added a reviewer: dsanders.
tomatabacu added a subscriber: Unknown Object (MLST).
dsanders accepted this revision.Dec 16 2014, 5:37 AM
dsanders edited edge metadata.

LGTM with a couple test improvements.

test/CodeGen/Mips/inlineasm-assembler-directives.ll
12

Please check for part of the inline assembly body before checking for the pop

test/CodeGen/Mips/inlineasmmemop.ll
8

Could you add a CHECK-LABEL for the function label? Likewise for main() below.

37–52

With the possible exception of line 42, this comment doesn't explain anything that isn't also written in the code below and actually disagrees with the code below in a couple details (the number of elements in the array and the order of the inline asm statements). Could you move the useful bit to the code below and delete the remainder in a follow-up?

This revision is now accepted and ready to land.Dec 16 2014, 5:37 AM
tomatabacu updated this revision to Diff 17381.Dec 17 2014, 2:02 AM
tomatabacu edited edge metadata.

Added CHECK's for the inline asm body.
Added CHECK-LABEL's for the 2 functions in inlineasmmemop.ll.

Will make further changes to inlineasmmemop.ll in a follow-up patch.

tomatabacu closed this revision.Dec 17 2014, 2:57 AM
lib/Target/Mips/MipsAsmPrinter.cpp