Search in sources :

Example 56 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorLitmusX86 method visitLoadValueToRegister.

@Override
public Object visitLoadValueToRegister(LitmusX86Parser.LoadValueToRegisterContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.register().getText(), ARCH_PRECISION);
    IValue constant = new IValue(new BigInteger(ctx.constant().getText()), ARCH_PRECISION);
    return programBuilder.addChild(mainThread, EventFactory.newLocal(register, constant));
}
Also used : IValue(com.dat3m.dartagnan.expression.IValue) Register(com.dat3m.dartagnan.program.Register) BigInteger(java.math.BigInteger)

Example 57 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class VisitorLitmusX86 method visitExchangeRegisterLocation.

@Override
public Object visitExchangeRegisterLocation(LitmusX86Parser.ExchangeRegisterLocationContext ctx) {
    Register register = programBuilder.getOrErrorRegister(mainThread, ctx.register().getText());
    MemoryObject object = programBuilder.getOrNewObject(ctx.location().getText());
    return programBuilder.addChild(mainThread, EventFactory.X86.newExchange(object, register));
}
Also used : Register(com.dat3m.dartagnan.program.Register) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject)

Example 58 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class AtomicProcedures method atomicFetchOp.

private static void atomicFetchOp(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    IExpr value = (IExpr) ctx.call_params().exprs().expr().get(1).accept(visitor);
    String mo = null;
    IOpBin op;
    if (ctx.getText().contains("_add")) {
        op = IOpBin.PLUS;
    } else if (ctx.getText().contains("_sub")) {
        op = IOpBin.MINUS;
    } else if (ctx.getText().contains("_and")) {
        op = IOpBin.AND;
    } else if (ctx.getText().contains("_or")) {
        op = IOpBin.OR;
    } else if (ctx.getText().contains("_xor")) {
        op = IOpBin.XOR;
    } else {
        throw new RuntimeException("AtomicFetchOp operation cannot be handled");
    }
    if (ctx.call_params().exprs().expr().size() > 2) {
        mo = intToMo(((IConst) ctx.call_params().exprs().expr().get(2).accept(visitor)).getValueAsInt());
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newFetchOp(reg, add, value, op, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : IOpBin(com.dat3m.dartagnan.expression.op.IOpBin) Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Example 59 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class AtomicProcedures method atomicXchg.

private static void atomicXchg(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    IExpr value = (IExpr) ctx.call_params().exprs().expr().get(1).accept(visitor);
    String mo = null;
    if (ctx.call_params().exprs().expr().size() > 2) {
        mo = intToMo(((IConst) ctx.call_params().exprs().expr().get(2).accept(visitor)).getValueAsInt());
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newExchange(reg, add, value, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Example 60 with Register

use of com.dat3m.dartagnan.program.Register in project Dat3M by hernanponcedeleon.

the class AtomicProcedures method atomicLoad.

private static void atomicLoad(VisitorBoogie visitor, Call_cmdContext ctx) {
    Register reg = visitor.programBuilder.getOrCreateRegister(visitor.threadCount, visitor.currentScope.getID() + ":" + ctx.call_params().Ident(0).getText(), ARCH_PRECISION);
    IExpr add = (IExpr) ctx.call_params().exprs().expr().get(0).accept(visitor);
    String mo = null;
    if (ctx.call_params().exprs().expr().size() > 1) {
        mo = intToMo(((IConst) ctx.call_params().exprs().expr().get(1).accept(visitor)).getValueAsInt());
    }
    visitor.programBuilder.addChild(visitor.threadCount, Atomic.newLoad(reg, add, mo)).setCLine(visitor.currentLine).setSourceCodeFile(visitor.sourceCodeFile);
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr) IConst(com.dat3m.dartagnan.expression.IConst)

Aggregations

Register (com.dat3m.dartagnan.program.Register)154 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)29 Event (com.dat3m.dartagnan.program.event.core.Event)25 IExpr (com.dat3m.dartagnan.expression.IExpr)16 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)15 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)13 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)12 Label (com.dat3m.dartagnan.program.event.core.Label)11 ParsingException (com.dat3m.dartagnan.exception.ParsingException)10 BigInteger (java.math.BigInteger)8 IConst (com.dat3m.dartagnan.expression.IConst)7 IExprBin (com.dat3m.dartagnan.expression.IExprBin)6 IValue (com.dat3m.dartagnan.expression.IValue)6 IOpBin (com.dat3m.dartagnan.expression.op.IOpBin)6 Program (com.dat3m.dartagnan.program.Program)6 Dependency (com.dat3m.dartagnan.program.analysis.Dependency)6 ExprInterface (com.dat3m.dartagnan.expression.ExprInterface)5 Thread (com.dat3m.dartagnan.program.Thread)5 java.util (java.util)5 Atom (com.dat3m.dartagnan.expression.Atom)4