source: icGREP/icgrep-devel/icgrep/pablo/pe_xor.cpp @ 4414

Last change on this file since 4414 was 4414, checked in by nmedfort, 5 years ago

Minor changes towards maintaining UseDef? information.

File size: 1016 bytes
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include <pablo/pe_xor.h>
8#include <pablo/codegenstate.h>
9
10namespace pablo {
11
12Xor::Xor(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent)
13: Statement(ClassTypeId::Xor, {{expr1, expr2}}, parent->makeName("xor"), parent)
14{
15
16}
17
18PabloAST * OptimizeXor::operator()(PabloAST * expr1, PabloAST * expr2, PabloBlock * pb) {
19    if (isa<Ones>(expr1)) {
20        return pb->createNot(expr2);
21    }
22    else if (isa<Zeroes>(expr1)){
23        return expr2;
24    }
25    else if (isa<Ones>(expr2)) {
26        return pb->createNot(expr1);
27    }
28    else if (isa<Zeroes>(expr2)){
29        return expr1;
30    }
31    else if (Not * not1 = dyn_cast<Not>(expr1)) {
32        if (Not * not2 = dyn_cast<Not>(expr2)) {
33            return pb->createXor(not1->getExpr(), not2->getExpr());
34        }
35    }
36    return pb->createXorImm(expr1, expr2);
37}
38
39}
Note: See TracBrowser for help on using the repository browser.