[PATCH] D55192: [PowerPC] VSX register support for inline assembly

Jinsong Ji via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 07:33:03 PST 2018


jsji added inline comments.


================
Comment at: clang/lib/Basic/Targets/PPC.cpp:416
+const TargetInfo::AddlRegName GCCAddlRegNames[] = {
+    {{"vs0"}, 0},   {{"vs1"}, 1},   {{"vs2"}, 2},   {{"vs3"}, 3}, 
+    {{"vs4"}, 4},   {{"vs5"}, 5},   {{"vs6"}, 6},   {{"vs7"}, 7},
----------------
jsji wrote:
> nemanjai wrote:
> > ZhangKang wrote:
> > > ZhangKang wrote:
> > > > ZhangKang wrote:
> > > > > jsji wrote:
> > > > > > RegNum is wrong here!
> > > > > > "vs0" should be mapped to RegNum of "f0", which is 33. 
> > > > > > "vs32" should be mapped to RegNum of "v0", which is 78.
> > > > > I will learn it and check it, thanks for your point out my error.
> > > > Here, the value of `AddlRegName` is responding to the gcc macro `ADDITIONAL_REGISTER_NAMES`. In the array `ADDITIONAL_REGISTER_NAMES`, `vs0~vs31` should be mapped to RegNum of `f0~f31`, which is `32~63`. And `vs32~vs63` should be mapped to RegNum of `v0~v31`, which is `77~108`.
> > > Below is the  `ADDITIONAL_REGISTER_NAMES` GCC manual said:
> > > ```
> > > Macro: ADDITIONAL_REGISTER_NAMES
> > > 
> > >     If defined, a C initializer for an array of structures containing a name and a register number. This macro defines additional names for hard registers, thus allowing the asm option in declarations to refer to registers using alternate names. 
> > > ```
> > Is it possible to just not use magic numbers here at all? Do these correspond to something that is available in .td files? Is any of this possibly subject to change? Or if it is defined in some predefined macro/system header, etc. can we use the values from there?
> Yes, should be 32-63, 77-108. I forgot to use 0 as index start.
This is fixed and defined in ABI, see ELFABIv2 "Table 2.26. Mappings of Common Registers". 
AFAIK all ABIs use the same encoding. 
Unfortunately, I don't think we have any td files or macros define these values.

@ZhangKang Please add a comment before this array, 
so that it is easier to find doc about how these RegNum encoding are defined.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55192/new/

https://reviews.llvm.org/D55192





More information about the llvm-commits mailing list