JDK-6516087 : ins_encode should support inline assembly using the MacroAssembler
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2007-01-22
  • Updated: 2010-04-02
  • Resolved: 2007-01-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u4Fixed 7Fixed hs10Fixed
IIn the adlc, the ins_encode construct is used with instruction
encodings that must be defined in the encode section.  This creates
several problems for reading the code as the assembly and the instruct
definition are far apart and you often have to duplicate the enc_class
if the types are different.  We'd like to encourage the use of
MacroAssembler for both readability and maintenance reasons so we'd
like to sweeten the syntax for defining encodings.  The simplest
version is to allow encoding classes to be specified inline with the
arguments implicitly defined.  Additionally we automatically construct
a MacroAssembler instance for use by the assembly.

For instance, this instruction defininition:

instruct addI_reg_reg(iRegI dst, iRegI src1, iRegI src2) %{
  match(Set dst (AddI src1 src2));

  format %{ "ADD    $src1,$src2,$dst" %}
  ins_encode %{
    __ add($src1$$Register, $src2$$Register, $dst$$Register);

will expand to this emit function

    // Define a MacroAssembler instance for use by the encoding.  The
    // name is chosen to match the __ idiom used for assembly in other
    // parts of hotspot and assumes the existence of the standard
    // #define __ _masm.
    MacroAssembler _masm(&cbuf);

    __ add(opnd_array(1)->as_Register(ra_,this,idx1), opnd_array(2)->as_Register(ra_,this,idx2), opnd_array(0)->as_Register(ra_,this));

I modified a couple instruction in sparc.ad and i486.ad to illustrate
this usage and also fixed the define for __ to be consistent across
files and with the adlc.  Someday we should switch it all to work this
way but for now I wanted to make it available for new encodings.

SUGGESTED FIX http://prt-web.sfbay.sun.com/net/prt-archiver.sfbay/data/archived_workspaces/main/c2_baseline/2007/20070123221745.never.6516087/workspace/webrevs/webrev-2007.01.24/index.html

EVALUATION see description