diff --git a/mx.sulong/mx_testsuites.py b/mx.sulong/mx_testsuites.py index ea9ea9fdf..168fb9d24 100644 --- a/mx.sulong/mx_testsuites.py +++ b/mx.sulong/mx_testsuites.py @@ -77,10 +77,10 @@ def run(vmArgs, unittest, versionFolder, extraOption=None): return mx_unittest.unittest(command) def run32(vmArgs, unittest, extraOption=None): - run(vmArgs + ['-Dsulong.LLVM=3.2'], unittest, 'v32', extraOption) + run(vmArgs, unittest, 'v32', extraOption) def run38(vmArgs, unittest, extraOption=None): - run(vmArgs + ['-Dsulong.LLVM=3.8'], unittest, 'v38', extraOption) + run(vmArgs, unittest, 'v38', extraOption) def runSulongSuite(vmArgs): """runs the Sulong test suite""" diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/IRVersionController.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/IRVersionController.java index 62c063906..6e909dd5d 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/IRVersionController.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/IRVersionController.java @@ -32,23 +32,22 @@ import java.util.List; import com.oracle.truffle.llvm.parser.listeners.constants.Constants; -import com.oracle.truffle.llvm.parser.listeners.constants.ConstantsVersion.ConstantsV32; -import com.oracle.truffle.llvm.parser.listeners.constants.ConstantsVersion.ConstantsV38; +import com.oracle.truffle.llvm.parser.listeners.constants.ConstantsVersion.ConstantsV1; +import com.oracle.truffle.llvm.parser.listeners.constants.ConstantsVersion.ConstantsV2; import com.oracle.truffle.llvm.parser.listeners.function.Function; -import com.oracle.truffle.llvm.parser.listeners.function.FunctionVersion.FunctionV32; -import com.oracle.truffle.llvm.parser.listeners.function.FunctionVersion.FunctionV38; +import com.oracle.truffle.llvm.parser.listeners.function.FunctionVersion.FunctionV1; +import com.oracle.truffle.llvm.parser.listeners.function.FunctionVersion.FunctionV2; import com.oracle.truffle.llvm.parser.listeners.metadata.Metadata; -import com.oracle.truffle.llvm.parser.listeners.metadata.MetadataVersion.MetadataV32; -import com.oracle.truffle.llvm.parser.listeners.metadata.MetadataVersion.MetadataV38; +import com.oracle.truffle.llvm.parser.listeners.metadata.MetadataVersion.MetadataV1; +import com.oracle.truffle.llvm.parser.listeners.metadata.MetadataVersion.MetadataV2; import com.oracle.truffle.llvm.parser.listeners.module.Module; import com.oracle.truffle.llvm.parser.listeners.module.ModuleVersionHelper; -import com.oracle.truffle.llvm.parser.listeners.module.ModuleVersionHelper.ModuleV32; -import com.oracle.truffle.llvm.parser.listeners.module.ModuleVersionHelper.ModuleV38; +import com.oracle.truffle.llvm.parser.listeners.module.ModuleVersionHelper.ModuleV1; +import com.oracle.truffle.llvm.parser.listeners.module.ModuleVersionHelper.ModuleV2; import com.oracle.truffle.llvm.parser.model.ModelModule; import com.oracle.truffle.llvm.parser.model.generators.ConstantGenerator; import com.oracle.truffle.llvm.parser.model.generators.FunctionGenerator; import com.oracle.truffle.llvm.parser.model.generators.SymbolGenerator; -import com.oracle.truffle.llvm.runtime.options.LLVMOptions; import com.oracle.truffle.llvm.runtime.types.Type; public final class IRVersionController { @@ -78,57 +77,41 @@ private interface FunctionParser { } private enum IRVersion { - DEFAULT(ModuleV32::new, FunctionV32::new, ConstantsV32::new, MetadataV32::new, "3.2", "3.3"), - LLVM_32(ModuleV32::new, FunctionV32::new, ConstantsV32::new, MetadataV32::new, "3.2", "3.3"), - LLVM_38(ModuleV38::new, FunctionV38::new, ConstantsV38::new, MetadataV38::new, "3.8", "3.9"); + DEFAULT(ModuleV1::new, FunctionV1::new, ConstantsV1::new, MetadataV1::new, -1), + LLVM_1(ModuleV1::new, FunctionV1::new, ConstantsV1::new, MetadataV1::new, 1), + LLVM_2(ModuleV2::new, FunctionV2::new, ConstantsV2::new, MetadataV2::new, 2); - private final String[] versionInformation; + private final int version; private final FunctionParser function; private final ConstantsParser constants; private final MetadataParser metadata; private final ModuleParser module; - IRVersion(ModuleParser module, FunctionParser function, ConstantsParser constants, MetadataParser metadata, String... strings) { + IRVersion(ModuleParser module, FunctionParser function, ConstantsParser constants, MetadataParser metadata, int version) { this.function = function; this.constants = constants; this.metadata = metadata; - this.versionInformation = strings; this.module = module; + this.version = version; } - - private boolean isVersion(String versionString) { - for (String v : versionInformation) { - if (versionString.contains(v)) { - return true; - } - } - return false; - } - } private IRVersion version; public IRVersionController() { - version = getVersion(LLVMOptions.ENGINE.llvmVersion()); + version = IRVersion.DEFAULT; } - public void setVersion(String versionStr) { - IRVersion newVersion = getVersion(versionStr); - if (version == IRVersion.DEFAULT || version == newVersion) { - version = newVersion; - } else { - throw new IllegalStateException(version.toString()); - } - } - - private static IRVersion getVersion(String versionStr) { - for (IRVersion v : IRVersion.values()) { - if (v.isVersion(versionStr)) { - return v; + public void setVersion(int versionNumber) { + if (version == IRVersion.DEFAULT) { + for (IRVersion candidate : IRVersion.values()) { + if (candidate.version == versionNumber) { + version = candidate; + return; + } } } - return IRVersion.DEFAULT; + throw new IllegalArgumentException("version: " + version); } public Metadata createMetadata(Types types, List symbols, SymbolGenerator generator) { diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/Identification.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/Identification.java index 85c4ec056..e0007feee 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/Identification.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/Identification.java @@ -29,22 +29,10 @@ */ package com.oracle.truffle.llvm.parser.listeners; -import com.oracle.truffle.llvm.parser.records.Records; - public final class Identification implements ParserListener { - private final IRVersionController versionController; - - public Identification(IRVersionController versionController) { - this.versionController = versionController; - } - @Override public void record(long id, long[] args) { - if (id == 1) { - String version = Records.toString(args); - versionController.setVersion(version); - } } } diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/constants/ConstantsVersion.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/constants/ConstantsVersion.java index 79d2695cc..bc3e7dfe9 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/constants/ConstantsVersion.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/constants/ConstantsVersion.java @@ -37,9 +37,9 @@ public final class ConstantsVersion { - public static class ConstantsV32 extends Constants { + public static class ConstantsV1 extends Constants { - public ConstantsV32(Types types, List symbols, ConstantGenerator generator) { + public ConstantsV1(Types types, List symbols, ConstantGenerator generator) { super(types, symbols, generator); } @@ -56,9 +56,9 @@ protected void createGetElementPointerExpression(long[] args, boolean isInbounds } - public static class ConstantsV38 extends Constants { + public static class ConstantsV2 extends Constants { - public ConstantsV38(Types types, List symbols, ConstantGenerator generator) { + public ConstantsV2(Types types, List symbols, ConstantGenerator generator) { super(types, symbols, generator); } diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/function/FunctionVersion.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/function/FunctionVersion.java index 73d375950..46d835523 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/function/FunctionVersion.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/function/FunctionVersion.java @@ -42,8 +42,8 @@ public final class FunctionVersion { - public static class FunctionV38 extends Function { - public FunctionV38(IRVersionController version, Types types, List symbols, FunctionGenerator generator, int mode) { + public static class FunctionV2 extends Function { + public FunctionV2(IRVersionController version, Types types, List symbols, FunctionGenerator generator, int mode) { super(version, types, symbols, generator, mode); } @@ -175,9 +175,9 @@ protected void createSwitch(long[] args) { } - public static class FunctionV32 extends Function { + public static class FunctionV1 extends Function { - public FunctionV32(IRVersionController version, Types types, List symbols, FunctionGenerator generator, int mode) { + public FunctionV1(IRVersionController version, Types types, List symbols, FunctionGenerator generator, int mode) { super(version, types, symbols, generator, mode); } diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/metadata/MetadataVersion.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/metadata/MetadataVersion.java index 1d941e899..ebc6a451a 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/metadata/MetadataVersion.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/metadata/MetadataVersion.java @@ -61,9 +61,9 @@ public final class MetadataVersion { - public static final class MetadataV38 extends Metadata { + public static final class MetadataV2 extends Metadata { - public MetadataV38(Types types, List symbols, SymbolGenerator generator) { + public MetadataV2(Types types, List symbols, SymbolGenerator generator) { super(types, symbols, generator); } @@ -81,9 +81,9 @@ public void createOldFnNode(long[] args, MetadataRecord record) { } - public static final class MetadataV32 extends Metadata { + public static final class MetadataV1 extends Metadata { - public MetadataV32(Types types, List symbols, SymbolGenerator generator) { + public MetadataV1(Types types, List symbols, SymbolGenerator generator) { super(types, symbols, generator); } diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/Module.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/Module.java index f98cdfc27..438d529f9 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/Module.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/Module.java @@ -145,8 +145,9 @@ public ParserListener enter(Block block) { return version.createFunction(types, sym, gen, mode); } + case IDENTIFICATION: - return new Identification(version); + return new Identification(); case TYPE: return types; @@ -174,6 +175,7 @@ public void record(long id, long[] args) { switch (record) { case VERSION: mode = (int) args[0]; + version.setVersion(mode); break; case TARGET_TRIPLE: diff --git a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/ModuleVersionHelper.java b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/ModuleVersionHelper.java index 7faf51b87..d9eadb7a1 100644 --- a/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/ModuleVersionHelper.java +++ b/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/listeners/module/ModuleVersionHelper.java @@ -39,7 +39,7 @@ public abstract class ModuleVersionHelper { public abstract FunctionType getFunctionType(Module m, long typeIndex); - public static final class ModuleV32 extends ModuleVersionHelper { + public static final class ModuleV1 extends ModuleVersionHelper { @Override public Type getGlobalType(Module m, long typeIndex) { @@ -53,7 +53,7 @@ public FunctionType getFunctionType(Module m, long typeIndex) { } - public static final class ModuleV38 extends ModuleVersionHelper { + public static final class ModuleV2 extends ModuleVersionHelper { @Override public Type getGlobalType(Module m, long typeIndex) { diff --git a/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java b/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java index b842d5fdb..f064305f8 100644 --- a/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java +++ b/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java @@ -36,9 +36,6 @@ @OptionCategory(name = "Base Options") abstract class SulongEngineOption { - @Option(commandLineName = "LLVM", help = "Version of the used LLVM File Format, e.g., 3.2 (default) or 3.8.", name = "llvmVersion") // - protected static final String LLVM_VERSION = "3.2"; - @Option(commandLineName = "NodeConfiguration", help = "The node configuration (node factory) to be used in Sulong.", name = "nodeConfiguration") // protected static final String NODE_CONFIGURATION = "default";