Ignore:
Timestamp:
Mar 24, 2017, 4:01:22 PM (3 years ago)
Author:
nmedfort
Message:

Bug fix for long advance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/array-test.cpp

    r5368 r5371  
    3434#include <iostream>
    3535
     36#include <pablo/passes/ssapass.h>
     37
    3638namespace llvm { class Type; }
    3739namespace pablo { class Integer; }
     
    7779    Var * matches = kernel->getOutputStreamVar("matches");
    7880
    79     PabloBuilder body = PabloBuilder::Create(pb);
    80 
    81     pb.createWhile(pending_lparen, body);
     81//    PabloBuilder outer = PabloBuilder::Create(pb);
     82
     83//    pb.createWhile(pending_lparen, outer);
     84
     85    PabloBuilder body = PabloBuilder::Create(pb); // outer
     86
     87    pb.createWhile(pending_lparen, body); // outer
    8288
    8389        PabloAST * adv_pending_lparen = body.createAdvance(pending_lparen, 1);
     
    117123
    118124}
    119 
    120 
    121 //void generate(PabloKernel * kernel) {
    122 
    123 //    PabloBuilder pb(kernel->getEntryBlock());
    124 
    125 //    Var * input = kernel->getInputStreamVar("input");
    126 
    127 //    PabloAST * basis[8];
    128 //    for (int i = 0; i < 8; ++i) {
    129 //        basis[i] = pb.createExtract(input, i);
    130 //    }
    131 
    132 //    PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
    133 //    PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
    134 //    PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
    135 //    PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
    136 //    PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
    137 //    PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
    138 //    PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
    139 //    PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
    140 //    PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
    141 //    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
    142 //    PabloAST * parens = pb.createOr(lparen, rparen, "parens");
    143 
    144 
    145 //    Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
    146 //    Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
    147 //    Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
    148 //    Var * const in_play = pb.createVar("in_play", parens);
    149 //    Var * const index = pb.createVar("i", pb.getInteger(0));
    150 
    151 //    Var * matches = kernel->getOutputStreamVar("matches");
    152 
    153 //    PabloBuilder body = PabloBuilder::Create(pb);
    154 
    155 //    pb.createWhile(pending_lparen, body);
    156 
    157 //        PabloAST * adv_pending_lparen = body.createAdvance(pending_lparen, 1);
    158 
    159 //        Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
    160 
    161 //        PabloBuilder ifPScan = PabloBuilder::Create(body);
    162 
    163 //        body.createIf(adv_pending_lparen, ifPScan); // <-- inefficient but tests whether we're probably calculating the summary later
    164 
    165 //            PabloAST * pscan = ifPScan.createScanTo(adv_pending_lparen, in_play, "pscan");
    166 
    167 //            ifPScan.createAssign(pending_lparen, ifPScan.createAnd(pscan, lparen));
    168 
    169 //            ifPScan.createAssign(closed_rparen, ifPScan.createAnd(pscan, rparen));
    170 
    171 //            ifPScan.createAssign(all_closed, ifPScan.createOr(all_closed, closed_rparen));
    172 
    173 //            // Mark any opening paren without a matching closer as an error.
    174 //            PabloAST * unmatched_lparen = ifPScan.createAtEOF(pscan, "unmatched_lparen");
    175 
    176 //            ifPScan.createAssign(accumulated_errors, ifPScan.createOr(accumulated_errors, unmatched_lparen));
    177 
    178 //            PabloAST * pending_rparen = ifPScan.createAnd(rparen, ifPScan.createNot(all_closed, "open_rparen"), "pending_rparen");
    179 
    180 //            ifPScan.createAssign(in_play, ifPScan.createOr(pending_lparen, pending_rparen));
    181 
    182 //        body.createAssign(body.createExtract(matches, index), closed_rparen);
    183 
    184 //        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
    185 
    186 //    // Mark any closing paren that was not actually used to close an opener as an error.
    187 //    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
    188 //    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
    189 
    190 //}
    191 
    192 //void generate(PabloKernel * kernel) {
    193 
    194 //    PabloBuilder pb(kernel->getEntryBlock());
    195 
    196 //    Var * input = kernel->getInputStreamVar("input");
    197 
    198 //    PabloAST * basis[8];
    199 //    for (int i = 0; i < 8; ++i) {
    200 //        basis[i] = pb.createExtract(input, i);
    201 //    }
    202 
    203 //    PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
    204 //    PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
    205 //    PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
    206 //    PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
    207 //    PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
    208 //    PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
    209 //    PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
    210 //    PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
    211 //    PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
    212 //    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
    213 //    PabloAST * parens = pb.createOr(lparen, rparen, "parens");
    214 
    215 
    216 //    Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
    217 //    Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
    218 //    Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
    219 //    Var * const in_play = pb.createVar("in_play", parens);
    220 //    Var * const index = pb.createVar("i", pb.getInteger(0));
    221 
    222 //    Var * matches = kernel->getOutputStreamVar("matches");
    223 
    224 //    PabloBuilder body = PabloBuilder::Create(pb);
    225 
    226 //    pb.createWhile(pending_lparen, body);
    227 
    228 //        PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
    229 
    230 //        Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
    231 
    232 //        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
    233 
    234 //        PabloBuilder ifPScan = PabloBuilder::Create(body);
    235 
    236 //        body.createIf(pscan, ifPScan);
    237 
    238 //            ifPScan.createAssign(closed_rparen, ifPScan.createAnd(pscan, rparen));
    239 
    240 //            ifPScan.createAssign(all_closed, ifPScan.createOr(all_closed, closed_rparen));
    241 
    242 //            // Mark any opening paren without a matching closer as an error.
    243 //            PabloAST * unmatched_lparen = ifPScan.createAtEOF(pscan, "unmatched_lparen");
    244 //            ifPScan.createAssign(accumulated_errors, ifPScan.createOr(accumulated_errors, unmatched_lparen));
    245 
    246 //            PabloAST * pending_rparen = ifPScan.createAnd(rparen, ifPScan.createNot(all_closed, "open_rparen"), "pending_rparen");
    247 
    248 //            ifPScan.createAssign(in_play, ifPScan.createOr(pending_lparen, pending_rparen));
    249 
    250 //            ifPScan.createAssign(ifPScan.createExtract(matches, index), closed_rparen);
    251 
    252 //        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
    253 
    254 //    // Mark any closing paren that was not actually used to close an opener as an error.
    255 //    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
    256 //    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
    257 
    258 //}
    259 
    260 //void generate(PabloKernel * kernel) {
    261 
    262 //    PabloBuilder pb(kernel->getEntryBlock());
    263 
    264 //    Var * input = kernel->getInputStreamVar("input");
    265 
    266 //    PabloAST * basis[8];
    267 //    for (int i = 0; i < 8; ++i) {
    268 //        basis[i] = pb.createExtract(input, i);
    269 //    }
    270 
    271 //    PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
    272 //    PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
    273 //    PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
    274 //    PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
    275 //    PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
    276 //    PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
    277 //    PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
    278 //    PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
    279 //    PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
    280 //    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
    281 //    PabloAST * parens = pb.createOr(lparen, rparen, "parens");
    282 
    283 
    284 //    Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
    285 //    Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
    286 //    Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
    287 //    Var * const in_play = pb.createVar("in_play", parens);
    288 //    Var * const index = pb.createVar("i", pb.getInteger(0));
    289 
    290 //    Var * matches = kernel->getOutputStreamVar("matches");
    291 
    292 //    PabloBuilder body = PabloBuilder::Create(pb);
    293 
    294 //    pb.createWhile(pending_lparen, body);
    295 
    296 //        PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
    297 
    298 //        PabloAST * closed_rparen = body.createAnd(pscan, rparen, "closed_rparen");
    299 //        body.createAssign(all_closed, body.createOr(all_closed, closed_rparen));
    300 
    301 //        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
    302 //        // Mark any opening paren without a matching closer as an error.
    303 //        PabloAST * unmatched_lparen = body.createAtEOF(pscan, "unmatched_lparen");
    304 //        body.createAssign(accumulated_errors, body.createOr(accumulated_errors, unmatched_lparen));
    305 
    306 //        body.createAssign(body.createExtract(matches, index), closed_rparen);
    307 
    308 //        PabloAST * pending_rparen = body.createAnd(rparen, body.createNot(all_closed, "open_rparen"), "pending_rparen");
    309 //        body.createAssign(in_play, body.createOr(pending_lparen, pending_rparen));
    310 //        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
    311 
    312 //    // Mark any closing paren that was not actually used to close an opener as an error.
    313 //    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
    314 //    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
    315 
    316 //}
    317125
    318126Function * pipeline(IDISA::IDISA_Builder * iBuilder, const unsigned count) {
     
    350158
    351159    generate(&bm);
     160//    SSAPass::transform(&bm);
     161
    352162//    pablo_function_passes(&bm);
    353163
Note: See TracChangeset for help on using the changeset viewer.