mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-06-10 10:29:36 +00:00
69 lines
2.3 KiB
Java
69 lines
2.3 KiB
Java
package dk.camelot64.kickc.fragment;
|
|
|
|
import dk.camelot64.kickc.fragment.signature.AsmFragmentSignature;
|
|
import dk.camelot64.kickc.model.TargetCpu;
|
|
import dk.camelot64.kickc.parser.KickCParser;
|
|
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* An ASM fragment template usable for generating KickAssembler code for different bindings.
|
|
* The AsmFragmentTemplateSynthesizer can generate multiple different templates usable for a specific fragment signature.
|
|
*/
|
|
public class AsmFragmentTemplateImpl implements AsmFragmentTemplate {
|
|
|
|
/** The fragment template signature name. */
|
|
private final AsmFragmentSignature signature;
|
|
/** The target CPU. */
|
|
private final TargetCpu targetCpu;
|
|
|
|
/** The parsed ASM lines. Initially null. Non-null after the template is used to generate ASM code. */
|
|
private final KickCParser.AsmLinesContext bodyAsm;
|
|
/** The ASM clobber of the fragment. Initially null. Non-null after the template is used to generate ASM code. */
|
|
private final AsmFragmentClobber clobber;
|
|
/** The cycles consumed by the ASM of the fragment. Initially null. Non-null after the template is used to generate ASM code. */
|
|
private final Double cycles;
|
|
|
|
AsmFragmentTemplateImpl(AsmFragmentSignature signature, TargetCpu targetCpu, KickCParser.AsmLinesContext bodyAsm, AsmFragmentClobber clobber, Double cycles) {
|
|
this.signature = signature;
|
|
this.targetCpu = targetCpu;
|
|
this.bodyAsm = bodyAsm;
|
|
this.clobber = clobber;
|
|
this.cycles = cycles;
|
|
}
|
|
|
|
public AsmFragmentSignature getSignature() {
|
|
return signature;
|
|
}
|
|
|
|
@Override
|
|
public KickCParser.AsmLinesContext getBodyAsm() {
|
|
return bodyAsm;
|
|
}
|
|
|
|
public TargetCpu getTargetCpu() {
|
|
return targetCpu;
|
|
}
|
|
|
|
public AsmFragmentClobber getClobber() {
|
|
return clobber;
|
|
}
|
|
|
|
public double getCycles() {
|
|
return cycles;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
AsmFragmentTemplateImpl that = (AsmFragmentTemplateImpl) o;
|
|
return signature.equals(that.signature) && targetCpu == that.targetCpu && Objects.equals(bodyAsm, that.bodyAsm);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(signature, targetCpu, bodyAsm);
|
|
}
|
|
}
|