This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using inline assembly with specific register indices


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Hi guys/ladies,

I'm currently designing an ISA add-on to the MIPS architecture. My
intention is to use it (it is an algorithm accelerator actually) as a
COP2 (coprocessor #2). The corresponding microarchitecture is stable
(works at register-transfer level, not subject to change). Plus, I
would be happy NOT TO CHANGE my ISA add-on.

My problem is that I would like to access specific indices in the data
register file of COP2, i.e. registers c2r0 to c2r31. This should be
done in inline assembly or else I'll have to put down probably 2k-3k
C-lines in assembly :-)

Is it possible to write down something like this:

asm("cop2a %0, %1;", :: "r" (cp2rb(i)) : "r" (cp2rb(j)));

where:
  i,j are indices to CP2RB, the data register file of coprocessor 2.
  %0,%1 denote the two source registers.

Is it possible to write intrinsics for accessing ***SPECIFIC***
register in the data register file of COP2??? That is for these
entries: cp2rb(i), cp2rb(j).

I'm considering writing wrappers for such cases like the following
snippet. This is a jump table in mixed C/MIPS assembly. It is an
example for the "mtc2" MIPS-I
instruction. It is not exactly the same case, since for the "cop2a"
instruction with the two source registers, IT WOULD NEED two nested
switches :-(
In addition to that, the jump tables cost 2-3 more instructions, which
would not happen if I re-write the target application in pure assembly.

- -- snippet starts --

// mtc2_wrapper
void mtc2_wrapper(unsigned int address_var, unsigned int data_var)
{
  // Copy data_var to CP2RB data register file at address address_var
  switch (address_var)
  {
    ...
    case 5:
      asm("mtc2 %0, $5;" :: "r" (data_var) : "$5");
      break;
    ...
  }
}

- -- snippet ends --

Any help is extemely appreciated!

Best regards
Nikolaos Kavvadias (a.k.a. "kavi")
<nkavv@physics.auth.gr>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
 
iD8DBQFCSSMEMPiy0tCWlz4RAptuAKCIeiksbxLfBAw5bRr0RrG15KD0DQCfftas
EKxem+g5tP2ehWsUmO6Jdo8=
=eAc/
-----END PGP SIGNATURE-----



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]