Search in sources :

Example 66 with Register

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

the class VisitorLitmusAArch64 method visitMov.

@Override
public Object visitMov(LitmusAArch64Parser.MovContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
    IExpr expr = ctx.expr32() != null ? (IExpr) ctx.expr32().accept(this) : (IExpr) ctx.expr64().accept(this);
    return programBuilder.addChild(mainThread, EventFactory.newLocal(register, expr));
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 67 with Register

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

the class VisitorLitmusAArch64 method visitStore.

@Override
public Object visitStore(LitmusAArch64Parser.StoreContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rV, ARCH_PRECISION);
    Register address = programBuilder.getOrErrorRegister(mainThread, ctx.address().id);
    if (ctx.offset() != null) {
        address = visitOffset(ctx.offset(), address);
    }
    return programBuilder.addChild(mainThread, EventFactory.newStore(address, register, ctx.storeInstruction().mo));
}
Also used : Register(com.dat3m.dartagnan.program.Register)

Example 68 with Register

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

the class VisitorLitmusAArch64 method visitLoadExclusive.

@Override
public Object visitLoadExclusive(LitmusAArch64Parser.LoadExclusiveContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
    Register address = programBuilder.getOrErrorRegister(mainThread, ctx.address().id);
    if (ctx.offset() != null) {
        address = visitOffset(ctx.offset(), address);
    }
    Load load = EventFactory.newRMWLoadExclusive(register, address, ctx.loadExclusiveInstruction().mo);
    return programBuilder.addChild(mainThread, load);
}
Also used : Load(com.dat3m.dartagnan.program.event.core.Load) Register(com.dat3m.dartagnan.program.Register)

Example 69 with Register

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

the class VisitorLitmusAArch64 method visitCmp.

@Override
public Object visitCmp(LitmusAArch64Parser.CmpContext ctx) {
    Register register = programBuilder.getOrCreateRegister(mainThread, ctx.rD, ARCH_PRECISION);
    IExpr expr = ctx.expr32() != null ? (IExpr) ctx.expr32().accept(this) : (IExpr) ctx.expr64().accept(this);
    return programBuilder.addChild(mainThread, EventFactory.newCompare(register, expr));
}
Also used : Register(com.dat3m.dartagnan.program.Register) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 70 with Register

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

the class ConstantPropagation method evaluate.

// TODO Once we have a lattice class this should be moved there.
private ExprInterface evaluate(ExprInterface input, Map<Register, ExprInterface> map) {
    ExprSimplifier simplifier = new ExprSimplifier();
    if (input instanceof INonDet || input instanceof BNonDet) {
        return TOP;
    }
    if (input instanceof IConst || input instanceof BConst) {
        return input;
    }
    if (input instanceof Register) {
        // have the key in the map.
        return map.getOrDefault(input, input);
    }
    if (input instanceof IExprUn) {
        IExprUn un = (IExprUn) input;
        IOpUn op = un.getOp();
        // These two can cause problems
        if (op.equals(BV2INT) || op.equals(BV2UINT)) {
            return input;
        }
        IExpr inner = (IExpr) evaluate(un.getInner(), map);
        return inner == TOP ? inner : new IExprUn(op, inner).visit(simplifier);
    }
    if (input instanceof IExprBin) {
        IExprBin bin = (IExprBin) input;
        IExpr lhs = (IExpr) evaluate(bin.getLHS(), map);
        IExpr rhs = (IExpr) evaluate(bin.getRHS(), map);
        return lhs == TOP || rhs == TOP ? TOP : new IExprBin(lhs, bin.getOp(), rhs).visit(simplifier);
    }
    if (input instanceof IfExpr) {
        IfExpr ife = (IfExpr) input;
        ExprInterface guard = evaluate(ife.getGuard(), map);
        IExpr tbranch = (IExpr) evaluate(ife.getTrueBranch(), map);
        IExpr fbranch = (IExpr) evaluate(ife.getFalseBranch(), map);
        return tbranch == TOP || fbranch == TOP || guard == TOP ? TOP : new IfExpr((BExpr) guard, tbranch, fbranch).visit(simplifier);
    }
    if (input instanceof Atom) {
        Atom atom = (Atom) input;
        ExprInterface lhs = evaluate(atom.getLHS(), map);
        ExprInterface rhs = evaluate(atom.getRHS(), map);
        return (lhs == TOP | rhs == TOP) ? TOP : new Atom(lhs, atom.getOp(), rhs).visit(simplifier);
    }
    if (input instanceof BExprUn) {
        BExprUn un = (BExprUn) input;
        BOpUn op = un.getOp();
        ExprInterface inner = evaluate(un.getInner(), map);
        return inner == TOP ? TOP : new BExprUn(op, inner).visit(simplifier);
    }
    if (input instanceof BExprBin) {
        BExprBin bin = (BExprBin) input;
        ExprInterface lhs = evaluate(bin.getLHS(), map);
        ExprInterface rhs = evaluate(bin.getRHS(), map);
        return (lhs == TOP | rhs == TOP) ? TOP : new BExprBin(lhs, bin.getOp(), rhs).visit(simplifier);
    }
    throw new UnsupportedOperationException(String.format("Expression %s not supported", input));
}
Also used : IOpUn(com.dat3m.dartagnan.expression.op.IOpUn) Register(com.dat3m.dartagnan.program.Register) ExprSimplifier(com.dat3m.dartagnan.expression.processing.ExprSimplifier) BOpUn(com.dat3m.dartagnan.expression.op.BOpUn)

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