Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Use binary version identifiers instead of textual #686

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mx.sulong/mx_testsuites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Type> symbols, SymbolGenerator generator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type> symbols, ConstantGenerator generator) {
public ConstantsV1(Types types, List<Type> symbols, ConstantGenerator generator) {
super(types, symbols, generator);
}

Expand All @@ -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<Type> symbols, ConstantGenerator generator) {
public ConstantsV2(Types types, List<Type> symbols, ConstantGenerator generator) {
super(types, symbols, generator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

public final class FunctionVersion {

public static class FunctionV38 extends Function {
public FunctionV38(IRVersionController version, Types types, List<Type> symbols, FunctionGenerator generator, int mode) {
public static class FunctionV2 extends Function {
public FunctionV2(IRVersionController version, Types types, List<Type> symbols, FunctionGenerator generator, int mode) {
super(version, types, symbols, generator, mode);
}

Expand Down Expand Up @@ -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<Type> symbols, FunctionGenerator generator, int mode) {
public FunctionV1(IRVersionController version, Types types, List<Type> symbols, FunctionGenerator generator, int mode) {
super(version, types, symbols, generator, mode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type> symbols, SymbolGenerator generator) {
public MetadataV2(Types types, List<Type> symbols, SymbolGenerator generator) {
super(types, symbols, generator);
}

Expand All @@ -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<Type> symbols, SymbolGenerator generator) {
public MetadataV1(Types types, List<Type> symbols, SymbolGenerator generator) {
super(types, symbols, generator);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down