freebsd-mips64 unhandled .cpsetup

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I'm taking a journey to try and get a clang/llvm build of freebsd-mips64
completed by grabbing various patches and enhancements from around the
internet and get them into one central place for review by all
concerned. (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197259#c11)

I've snagged some patches for MIPS from cheri-bsd and some from pending
MIPS reviews in phabricator but seem to be stuck on handling .cpsetup
when building gnu csu bits, specifically:

End of search list.
<inline asm>:6:20: error: expected identifier
        .cpsetup $31, $2, 1b
                          ^
Assertion failed: (!Name.empty() && "Normal symbols cannot be
unnamed!"), function GetOrCreateSymbol, file
/home/sbruno/bsd/clang360-import/lib/clang/libllvmmc/../../../contrib/llvm/lib/MC/MCContext.cpp,
line 101.

Obviously, this is handled by gcc "just fine" in our case, but I'm more
interested in moving forward to clang. :slight_smile:

sean

Moving to llvmdev, as this is not a clang issue.

David

I've had a quick look and it seems the problem is that we're parsing the last operand with parseIdentifier() which doesn't have any of the code to handle relative symbols like '1b' or '1f'. I think we need to be using parseExpression() like we do in parseJumpTarget() and parseImm().

Toma: Could you look into fixing this along with the other integrated assembler issues you are working on?

Yes, I'll look into it.

Regards,
Toma Tabacu

Toma:

Hey, I'm the bsd nerd trying to get our mips target switched over to clang/llvm. I looked at switching the mips asm parser over to
parseExpression() but I am unfamiliar with the syntax to do this for .cpsetup.

If you do look into this, let me know and I'll bang on it in my
clang36 pre-release tree.

sean

Hi,

I've managed to replace parseIdentifier() with parseExpression() and you're
example doesn't give an error anymore, but I'm not sure that what we end up
generating is correct. I need a little more time to find out.

In the meantime, could you open a ticket on llvm.org/bugs ?

Thanks for working on this, btw !

Regards,
Toma Tabacu

Toma:

Just wondering if you want me to poke at anything to validate.

sean

From: Sean Bruno [mailto:sbruno@ignoranthack.me]
Sent: 16 February 2015 19:08
To: Toma Tabacu; Daniel Sanders; LLVM Dev
Subject: Re: [cfe-dev] freebsd-mips64 unhandled .cpsetup

Toma:

Just wondering if you want me to poke at anything to validate.

sean

Could you please try http://reviews.llvm.org/D7697 and let me know if it works for you ?

Regards,
Toma Tabacu

Seems "good" to me. At least, I move forward down the compile chain
of errors and .cpsetup is accepted as valid syntax.

sean

This is fixed by Toma's work at:

http://llvm.org/viewvc/llvm-project?view=revision&revision=229671

sean