nodeIntrinsic to load an hsail kernarg

Deneau, Tom tom.deneau at amd.com
Thu May 15 21:11:08 UTC 2014


I would like to create special HSAILNode with a @NodeIntrinsic which would end up generating HSAIL code to load from a named kernarg.  So for instance if the kernel prologue had
     align 8 kernarg_f64  %_foo,

I could write snippet code something like
         double someVar = HSAILKernArgNode.loadDouble("%_foo");

and have it end up generating the following HSAIL

         ld_kernarg_f64   $dxx, [%_foo]

where $dxx represents the register assigned to someVar.

I'm not sure of the best template to use for such a node.
I tried the one shown below and when I compile with the HSAIL backend, it appears not be recognizing the @NodeIntrinsic annotation but just generating the regular body of the loadDouble method.

I should add that at the moment I have not fully implemented this in the LIR and so in the HSAILLIRGenerator we have

	public Value emitLoadKernArg(Kind kind, String argName) {
        throw GraalInternalError.unimplemented();
	}

===========================
public class HSAILKernArgNode extends FloatingNode implements Canonicalizable {
    
    private final String argName;

    public String getArgName() {
        return argName;
    }

    /**
     * Creates a new HSAILKernArgNode.
     *
     */
    public HSAILKernArgNode(Kind kind, String argName) {
        super(StampFactory.forKind(kind));
        this.argName = argName;
    }

    public void generate(NodeLIRBuilderTool gen) {
    HSAILLIRGenerator hsailgen = (HSAILLIRGenerator)(gen.getLIRGeneratorTool());
        Value result = hsailgen.emitLoadKernArg(getKind(), getArgName());
        gen.setResult(this, result);
    }

    @Override
    public Node canonical(CanonicalizerTool tool) {
        return this;
    }

    @NodeIntrinsic
    public static double loadDouble(Kind kind, @ConstantNodeParameter String argName) {
        return 42.1;   // filler code
    }


    public static double loadDouble(String argName) {
        return loadDouble(Kind.Double, argName);
    }

}


-- Tom




More information about the graal-dev mailing list