on master help sign in
Remove Buffer/BitVectors from compiler/C rts
8472966Edwin Brady
rts/idris_bitstring.c−68
@@ -822,71 +822,3 @@ VAL idris_b64T32(VM *vm, VAL a) {
822 return cl;
822 return cl;
823}
823}
824
824
825−// SSE vectors
826−VAL idris_IDXB8x16(VM* vm, VAL vec, VAL idx) {
827− __m128i sse = *vec->info.bits128p;
828− uint8_t data[16];
829− _mm_storeu_si128((__m128i*)&data, sse);
830− return MKB8(vm, data[idx->info.bits32]);
831−}
832−
833−VAL idris_IDXB16x8(VM* vm, VAL vec, VAL idx) {
834− __m128i sse = *vec->info.bits128p;
835− uint16_t data[8];
836− _mm_storeu_si128((__m128i*)&data, sse);
837− return MKB16(vm, data[idx->info.bits32]);
838−}
839−
840−VAL idris_IDXB32x4(VM* vm, VAL vec, VAL idx) {
841− __m128i sse = *vec->info.bits128p;
842− uint32_t data[4];
843− _mm_storeu_si128((__m128i*)&data, sse);
844− return MKB32(vm, data[idx->info.bits32]);
845−}
846−
847−VAL idris_IDXB64x2(VM* vm, VAL vec, VAL idx) {
848− __m128i sse = *vec->info.bits128p;
849− uint64_t data[2];
850− _mm_storeu_si128((__m128i*)&data, sse);
851− return MKB64(vm, data[idx->info.bits32]);
852−}
853−
854−VAL idris_b8x16CopyForGC(VM *vm, VAL vec) {
855− __m128i sse = *vec->info.bits128p;
856− VAL cl = allocate(sizeof(Closure) + 16 + sizeof(__m128i), 1);
857− SETTY(cl, BITS8X16);
858− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
859− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
860− *cl->info.bits128p = sse;
861− return cl;
862−}
863−
864−VAL idris_b16x8CopyForGC(VM *vm, VAL vec) {
865− __m128i sse = *vec->info.bits128p;
866− VAL cl = allocate(sizeof(Closure) + 16 + sizeof(__m128i), 1);
867− SETTY(cl, BITS16X8);
868− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
869− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
870− *cl->info.bits128p = sse;
871− return cl;
872−}
873−
874−VAL idris_b32x4CopyForGC(VM *vm, VAL vec) {
875− __m128i sse = *vec->info.bits128p;
876− VAL cl = allocate(sizeof(Closure) + 16 + sizeof(__m128i), 1);
877− SETTY(cl, BITS32X4);
878− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
879− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
880− *cl->info.bits128p = sse;
881− return cl;
882−}
883−
884−VAL idris_b64x2CopyForGC(VM *vm, VAL vec) {
885− __m128i sse = *vec->info.bits128p;
886− VAL cl = allocate(sizeof(Closure) + 16 + sizeof(__m128i), 1);
887− SETTY(cl, BITS64X2);
888− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
889− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
890− *cl->info.bits128p = sse;
891− return cl;
892−}
rts/idris_bitstring.h−10
@@ -126,14 +126,4 @@ VAL idris_b64T8(VM *vm, VAL a);
126VAL idris_b64T16(VM *vm, VAL a);
126VAL idris_b64T16(VM *vm, VAL a);
127VAL idris_b64T32(VM *vm, VAL a);
127VAL idris_b64T32(VM *vm, VAL a);
128
128
129−VAL idris_IDXB8x16(VM* vm, VAL vec, VAL idx);
130−VAL idris_IDXB16x8(VM* vm, VAL vec, VAL idx);
131−VAL idris_IDXB32x4(VM* vm, VAL vec, VAL idx);
132−VAL idris_IDXB64x2(VM* vm, VAL vec, VAL idx);
133−
134−VAL idris_b8x16CopyForGC(VM *vm, VAL a);
135−VAL idris_b16x8CopyForGC(VM *vm, VAL a);
136−VAL idris_b32x4CopyForGC(VM *vm, VAL a);
137−VAL idris_b64x2CopyForGC(VM *vm, VAL a);
138−
139#endif
129#endif
rts/idris_gc.c−15
@@ -30,9 +30,6 @@ VAL copy(VM* vm, VAL x) {
30 case STROFFSET:
30 case STROFFSET:
31 cl = MKSTROFFc(vm, x->info.str_offset);
31 cl = MKSTROFFc(vm, x->info.str_offset);
32 break;
32 break;
33− case BUFFER:
34− cl = MKBUFFERc(vm, x->info.buf);
35− break;
36 case BIGINT:
33 case BIGINT:
37 cl = MKBIGMc(vm, x->info.ptr);
34 cl = MKBIGMc(vm, x->info.ptr);
38 break;
35 break;
@@ -54,18 +51,6 @@ VAL copy(VM* vm, VAL x) {
54 case BITS64:
51 case BITS64:
55 cl = idris_b64CopyForGC(vm, x);
52 cl = idris_b64CopyForGC(vm, x);
56 break;
53 break;
57− case BITS8X16:
58− cl = idris_b8x16CopyForGC(vm, x);
59− break;
60− case BITS16X8:
61− cl = idris_b16x8CopyForGC(vm, x);
62− break;
63− case BITS32X4:
64− cl = idris_b32x4CopyForGC(vm, x);
65− break;
66− case BITS64X2:
67− cl = idris_b64x2CopyForGC(vm, x);
68− break;
69 case FWD:
54 case FWD:
70 return x->info.ptr;
55 return x->info.ptr;
71 default:
56 default:
rts/idris_rts.c−338
@@ -327,107 +327,6 @@ VAL MKB64(VM* vm, uint64_t bits64) {
327 return cl;
327 return cl;
328}
328}
329
329
330−VAL MKB8x16const(VM* vm,
331− uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3,
332− uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
333− uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11,
334− uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15) {
335− Closure* cl = allocate(sizeof(Closure) + sizeof(__m128i), 1);
336− SETTY(cl, BITS8X16);
337−
338− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
339− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
340−
341− uint8_t data[16];
342− data[0]=v0; data[1]=v1; data[2]=v2; data[3]=v3;
343− data[4]=v4; data[5]=v5; data[6]=v6; data[7]=v7;
344− data[8]=v8; data[9]=v9; data[10]=v10; data[11]=v11;
345− data[12]=v12; data[13]=v13; data[14]=v14; data[15]=v15;
346−
347− *cl->info.bits128p = _mm_loadu_si128((__m128i*)&data);
348−
349− return cl;
350−}
351−
352−VAL MKB8x16(VM* vm,
353− VAL v0, VAL v1, VAL v2, VAL v3,
354− VAL v4, VAL v5, VAL v6, VAL v7,
355− VAL v8, VAL v9, VAL v10, VAL v11,
356− VAL v12, VAL v13, VAL v14, VAL v15) {
357− return MKB8x16const(vm,
358− v0->info.bits8, v1->info.bits8, v2->info.bits8, v3->info.bits8,
359− v4->info.bits8, v5->info.bits8, v6->info.bits8, v7->info.bits8,
360− v8->info.bits8, v9->info.bits8, v10->info.bits8, v11->info.bits8,
361− v12->info.bits8, v13->info.bits8, v14->info.bits8, v15->info.bits8);
362−}
363−
364−VAL MKB16x8const(VM* vm,
365− uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3,
366− uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7) {
367− Closure* cl = allocate(sizeof(Closure) + sizeof(__m128i), 1);
368− SETTY(cl, BITS16X8);
369−
370− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
371− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
372−
373− uint16_t data[8];
374− data[0]=v0; data[1]=v1; data[2]=v2; data[3]=v3;
375− data[4]=v4; data[5]=v5; data[6]=v6; data[7]=v7;
376−
377− *cl->info.bits128p = _mm_loadu_si128((__m128i*)&data);
378− return cl;
379−
380−}
381−
382−VAL MKB16x8(VM* vm,
383− VAL v0, VAL v1, VAL v2, VAL v3,
384− VAL v4, VAL v5, VAL v6, VAL v7) {
385− return MKB16x8const(vm,
386− v0->info.bits16, v1->info.bits16, v2->info.bits16, v3->info.bits16,
387− v4->info.bits16, v5->info.bits16, v6->info.bits16, v7->info.bits16);
388−}
389−
390−VAL MKB32x4const(VM* vm,
391− uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3) {
392− Closure* cl = allocate(sizeof(Closure) + 16 + sizeof(__m128i), 1);
393− SETTY(cl, BITS64X2);
394−
395− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
396− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
397−
398− uint32_t data[4];
399− data[0]=v0; data[1]=v1; data[2]=v2; data[3]=v3;
400−
401− *cl->info.bits128p = _mm_loadu_si128((__m128i*)&data);
402− return cl;
403−}
404−
405−VAL MKB32x4(VM* vm,
406− VAL v0, VAL v1, VAL v2, VAL v3) {
407− return MKB32x4const(vm,
408− v0->info.bits32, v1->info.bits32, v2->info.bits32, v3->info.bits32);
409−}
410−
411−VAL MKB64x2const(VM* vm, uint64_t v0, uint64_t v1) {
412− Closure* cl = allocate(sizeof(Closure) + 16 + sizeof(__m128i), 1);
413− SETTY(cl, BITS64X2);
414−
415− cl->info.bits128p = (__m128i*)ALIGN((uintptr_t)cl + sizeof(Closure), 16);
416− assert ((uintptr_t)cl->info.bits128p % 16 == 0);
417−
418− uint64_t data[2];
419− data[0]=v0; data[1]=v1;
420−
421− *cl->info.bits128p = _mm_loadu_si128((__m128i*)&data);
422− return cl;
423−}
424−
425−VAL MKB64x2(VM* vm, VAL v0, VAL v1) {
426− return MKB64x2const(vm,
427− v0->info.bits64,
428− v1->info.bits64);
429−}
430−
431void PROJECT(VM* vm, VAL r, int loc, int arity) {
330void PROJECT(VM* vm, VAL r, int loc, int arity) {
432 int i;
331 int i;
433 for(i = 0; i < arity; ++i) {
332 for(i = 0; i < arity; ++i) {
@@ -740,240 +639,6 @@ VAL idris_systemInfo(VM* vm, VAL index) {
740 return MKSTR(vm, "");
639 return MKSTR(vm, "");
741}
640}
742
641
743−VAL MKBUFFERc(VM* vm, Buffer* buf) {
744− Closure* cl = allocate(sizeof(Closure) + sizeof *buf + buf->cap, 1);
745− SETTY(cl, BUFFER);
746− cl->info.buf = (Buffer*)((void*)cl + sizeof(Closure));
747− memmove(cl->info.buf, buf, sizeof *buf + buf->fill);
748− return cl;
749−}
750−
751−static VAL internal_allocate(VM *vm, size_t hint) {
752− size_t size = hint + sizeof(Closure) + sizeof(Buffer);
753−
754− // Round up to a power of 2
755− --size;
756− size_t i;
757− for (i = 0; i <= sizeof size; ++i)
758− size |= size >> (1 << i);
759− ++size;
760−
761− Closure* cl = allocate(size, 0);
762− SETTY(cl, BUFFER);
763− cl->info.buf = (Buffer*)((void*)cl + sizeof(Closure));
764− cl->info.buf->cap = size - (sizeof(Closure) + sizeof(Buffer));
765− return cl;
766−}
767−
768−// Following functions cast uint64_t to size_t, which may narrow!
769−VAL idris_buffer_allocate(VM* vm, VAL hint) {
770− Closure* cl = internal_allocate(vm, hint->info.bits64);
771− cl->info.buf->fill = 0;
772− return cl;
773−}
774−
775−static void internal_memset(void *dest, const void *src, size_t size, size_t num) {
776− while (num--) {
777− memmove(dest, src, size);
778− dest += size;
779− }
780−}
781−
782−static VAL internal_prepare_append(VM* vm, VAL buf, size_t bufLen, size_t appLen) {
783− size_t totalLen = bufLen + appLen;
784− Closure* cl;
785− if (bufLen != buf->info.buf->fill ||
786− totalLen > buf->info.buf->cap) {
787− // We're not at the fill or are over cap, so need a new buffer
788− cl = internal_allocate(vm, totalLen);
789− memmove(cl->info.buf->store,
790− buf->info.buf->store,
791− bufLen);
792− cl->info.buf->fill = totalLen;
793− } else {
794− // Hooray, can just bump the fill
795− cl = buf;
796− cl->info.buf->fill += appLen;
797− }
798− return cl;
799−}
800−
801−VAL idris_appendBuffer(VM* vm, VAL fst, VAL fstLen, VAL cnt, VAL sndLen, VAL sndOff, VAL snd) {
802− size_t firstLength = fstLen->info.bits64;
803− size_t secondLength = sndLen->info.bits64;
804− size_t count = cnt->info.bits64;
805− size_t offset = sndOff->info.bits64;
806− Closure* cl = internal_prepare_append(vm, fst, firstLength, count * secondLength);
807− internal_memset(cl->info.buf->store + firstLength, snd->info.buf->store + offset, secondLength, count);
808− return cl;
809−}
810−
811−// Special cased because we can use memset
812−VAL idris_appendB8Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
813− size_t bufLen = len->info.bits64;
814− size_t count = cnt->info.bits64;
815− Closure* cl = internal_prepare_append(vm, buf, bufLen, count);
816− memset(cl->info.buf->store + bufLen, val->info.bits8, count);
817− return cl;
818−}
819−
820−static VAL internal_append_bits(VM* vm, VAL buf, VAL bufLen, VAL cnt, const void* val, size_t val_len) {
821− size_t len = bufLen->info.bits64;
822− size_t count = cnt->info.bits64;
823− Closure* cl = internal_prepare_append(vm, buf, len, count * val_len);
824− internal_memset(cl->info.buf->store + len, val, val_len, count);
825− return cl;
826−}
827−
828−VAL idris_appendB16Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
829− return internal_append_bits(vm, buf, len, cnt, &val->info.bits16, sizeof val->info.bits16);
830−}
831−
832−VAL idris_appendB16LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
833− // On gcc 4.8 -O3 compiling for x86_64, using leVal like this is
834− // optimized away. Presumably the same holds for other sizes and
835− // conversly on BE systems
836− unsigned char leVal[sizeof val] = { val->info.bits16
837− , (val->info.bits16 >> 8)
838− };
839− return internal_append_bits(vm, buf, len, cnt, leVal, sizeof leVal);
840−}
841−
842−VAL idris_appendB16BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
843− unsigned char beVal[sizeof val] = { (val->info.bits16 >> 8)
844− , val->info.bits16
845− };
846− return internal_append_bits(vm, buf, len, cnt, beVal, sizeof beVal);
847−}
848−
849−VAL idris_appendB32Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
850− return internal_append_bits(vm, buf, len, cnt, &val->info.bits32, sizeof val->info.bits32);
851−}
852−
853−VAL idris_appendB32LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
854− unsigned char leVal[sizeof val] = { val->info.bits32
855− , (val->info.bits32 >> 8)
856− , (val->info.bits32 >> 16)
857− , (val->info.bits32 >> 24)
858− };
859− return internal_append_bits(vm, buf, len, cnt, leVal, sizeof leVal);
860−}
861−
862−VAL idris_appendB32BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
863− unsigned char beVal[sizeof val] = { (val->info.bits32 >> 24)
864− , (val->info.bits32 >> 16)
865− , (val->info.bits32 >> 8)
866− , val->info.bits32
867− };
868− return internal_append_bits(vm, buf, len, cnt, beVal, sizeof beVal);
869−}
870−
871−VAL idris_appendB64Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
872− return internal_append_bits(vm, buf, len, cnt, &val->info.bits64, sizeof val->info.bits64);
873−}
874−
875−VAL idris_appendB64LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
876− unsigned char leVal[sizeof val] = { val->info.bits64
877− , (val->info.bits64 >> 8)
878− , (val->info.bits64 >> 16)
879− , (val->info.bits64 >> 24)
880− , (val->info.bits64 >> 32)
881− , (val->info.bits64 >> 40)
882− , (val->info.bits64 >> 48)
883− , (val->info.bits64 >> 56)
884− };
885− return internal_append_bits(vm, buf, len, cnt, leVal, sizeof leVal);
886−}
887−
888−VAL idris_appendB64BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
889− unsigned char beVal[sizeof val] = { (val->info.bits64 >> 56)
890− , (val->info.bits64 >> 48)
891− , (val->info.bits64 >> 40)
892− , (val->info.bits64 >> 32)
893− , (val->info.bits64 >> 24)
894− , (val->info.bits64 >> 16)
895− , (val->info.bits64 >> 8)
896− , val->info.bits64
897− };
898− return internal_append_bits(vm, buf, len, cnt, beVal, sizeof beVal);
899−}
900−
901−VAL idris_peekB8Native(VM* vm, VAL buf, VAL off) {
902− size_t offset = off->info.bits64;
903− uint8_t *val = buf->info.buf->store + offset;
904− return MKB8(vm, *val);
905−}
906−
907−VAL idris_peekB16Native(VM* vm, VAL buf, VAL off) {
908− size_t offset = off->info.bits64;
909− uint16_t *val = (uint16_t *) (buf->info.buf->store + offset);
910− return MKB16(vm, *val);
911−}
912−
913−VAL idris_peekB16LE(VM* vm, VAL buf, VAL off) {
914− size_t offset = off->info.bits64;
915− return MKB16(vm, ((uint16_t) buf->info.buf->store[offset]) +
916− (((uint16_t) buf->info.buf->store[offset + 1]) << 8));
917−}
918−
919−VAL idris_peekB16BE(VM* vm, VAL buf, VAL off) {
920− size_t offset = off->info.bits64;
921− return MKB16(vm, ((uint16_t) buf->info.buf->store[offset + 1]) +
922− (((uint16_t) buf->info.buf->store[offset]) << 8));
923−}
924−
925−VAL idris_peekB32Native(VM* vm, VAL buf, VAL off) {
926− size_t offset = off->info.bits64;
927− uint32_t *val = (uint32_t *) (buf->info.buf->store + offset);
928− return MKB32(vm, *val);
929−}
930−
931−VAL idris_peekB32LE(VM* vm, VAL buf, VAL off) {
932− size_t offset = off->info.bits64;
933− return MKB32(vm, ((uint32_t) buf->info.buf->store[offset]) +
934− (((uint32_t) buf->info.buf->store[offset + 1]) << 8) +
935− (((uint32_t) buf->info.buf->store[offset + 2]) << 16) +
936− (((uint32_t) buf->info.buf->store[offset + 3]) << 24));
937−}
938−
939−VAL idris_peekB32BE(VM* vm, VAL buf, VAL off) {
940− size_t offset = off->info.bits64;
941− return MKB32(vm, ((uint32_t) buf->info.buf->store[offset + 3]) +
942− (((uint32_t) buf->info.buf->store[offset + 2]) << 8) +
943− (((uint32_t) buf->info.buf->store[offset + 1]) << 16) +
944− (((uint32_t) buf->info.buf->store[offset]) << 24));
945−}
946−
947−VAL idris_peekB64Native(VM* vm, VAL buf, VAL off) {
948− size_t offset = off->info.bits64;
949− uint64_t *val = (uint64_t *) (buf->info.buf->store + offset);
950− return MKB64(vm, *val);
951−}
952−
953−VAL idris_peekB64LE(VM* vm, VAL buf, VAL off) {
954− size_t offset = off->info.bits64;
955− return MKB64(vm, ((uint64_t) buf->info.buf->store[offset]) +
956− (((uint64_t) buf->info.buf->store[offset + 1]) << 8) +
957− (((uint64_t) buf->info.buf->store[offset + 2]) << 16) +
958− (((uint64_t) buf->info.buf->store[offset + 3]) << 24) +
959− (((uint64_t) buf->info.buf->store[offset + 4]) << 32) +
960− (((uint64_t) buf->info.buf->store[offset + 5]) << 40) +
961− (((uint64_t) buf->info.buf->store[offset + 6]) << 48) +
962− (((uint64_t) buf->info.buf->store[offset + 7]) << 56));
963−}
964−
965−VAL idris_peekB64BE(VM* vm, VAL buf, VAL off) {
966− size_t offset = off->info.bits64;
967− return MKB64(vm, ((uint64_t) buf->info.buf->store[offset + 7]) +
968− (((uint64_t) buf->info.buf->store[offset + 6]) << 8) +
969− (((uint64_t) buf->info.buf->store[offset + 5]) << 16) +
970− (((uint64_t) buf->info.buf->store[offset + 4]) << 24) +
971− (((uint64_t) buf->info.buf->store[offset + 3]) << 32) +
972− (((uint64_t) buf->info.buf->store[offset + 2]) << 40) +
973− (((uint64_t) buf->info.buf->store[offset + 1]) << 48) +
974− (((uint64_t) buf->info.buf->store[offset]) << 56));
975−}
976−
977typedef struct {
642typedef struct {
978 VM* vm; // thread's VM
643 VM* vm; // thread's VM
979 VM* callvm; // calling thread's VM
644 VM* callvm; // calling thread's VM
@@ -1058,9 +723,6 @@ VAL doCopyTo(VM* vm, VAL x) {
1058 case STRING:
723 case STRING:
1059 cl = MKSTRc(vm, x->info.str);
724 cl = MKSTRc(vm, x->info.str);
1060 break;
725 break;
1061− case BUFFER:
1062− cl = MKBUFFERc(vm, x->info.buf);
1063− break;
1064 case BIGINT:
726 case BIGINT:
1065 cl = MKBIGMc(vm, x->info.ptr);
727 cl = MKBIGMc(vm, x->info.ptr);
1066 break;
728 break;
rts/idris_rts.h+1−30
@@ -26,8 +26,7 @@
26typedef enum {
26typedef enum {
27 CON, INT, BIGINT, FLOAT, STRING, STROFFSET,
27 CON, INT, BIGINT, FLOAT, STRING, STROFFSET,
28 BITS8, BITS16, BITS32, BITS64, UNIT, PTR, FWD,
28 BITS8, BITS16, BITS32, BITS64, UNIT, PTR, FWD,
29− MANAGEDPTR, BUFFER, BITS8X16, BITS16X8, BITS32X4,
29+ MANAGEDPTR
30− BITS64X2
31} ClosureType;
30} ClosureType;
32
31
33typedef struct Closure *VAL;
32typedef struct Closure *VAL;
@@ -208,37 +207,12 @@ VAL MKB16(VM* vm, uint16_t b);
208VAL MKB32(VM* vm, uint32_t b);
207VAL MKB32(VM* vm, uint32_t b);
209VAL MKB64(VM* vm, uint64_t b);
208VAL MKB64(VM* vm, uint64_t b);
210
209
211−// SSE Vectors
212−VAL MKB8x16(VM* vm,
213− VAL v0, VAL v1, VAL v2, VAL v3,
214− VAL v4, VAL v5, VAL v6, VAL v7,
215− VAL v8, VAL v9, VAL v10, VAL v11,
216− VAL v12, VAL v13, VAL v14, VAL v15);
217−VAL MKB8x16const(VM* vm,
218− uint8_t v0, uint8_t v1, uint8_t v2, uint8_t v3,
219− uint8_t v4, uint8_t v5, uint8_t v6, uint8_t v7,
220− uint8_t v8, uint8_t v9, uint8_t v10, uint8_t v11,
221− uint8_t v12, uint8_t v13, uint8_t v14, uint8_t v15);
222−VAL MKB16x8(VM* vm,
223− VAL v0, VAL v1, VAL v2, VAL v3,
224− VAL v4, VAL v5, VAL v6, VAL v7);
225−VAL MKB16x8const(VM* vm,
226− uint16_t v0, uint16_t v1, uint16_t v2, uint16_t v3,
227− uint16_t v4, uint16_t v5, uint16_t v6, uint16_t v7);
228−VAL MKB32x4(VM* vm,
229− VAL v0, VAL v1, VAL v2, VAL v3);
230−VAL MKB32x4const(VM* vm,
231− uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3);
232−VAL MKB64x2(VM* vm, VAL v0, VAL v1);
233−VAL MKB64x2const(VM* vm, uint64_t v0, uint64_t v1);
234−
235// following versions don't take a lock when allocating
210// following versions don't take a lock when allocating
236VAL MKFLOATc(VM* vm, double val);
211VAL MKFLOATc(VM* vm, double val);
237VAL MKSTROFFc(VM* vm, StrOffset* off);
212VAL MKSTROFFc(VM* vm, StrOffset* off);
238VAL MKSTRc(VM* vm, char* str);
213VAL MKSTRc(VM* vm, char* str);
239VAL MKPTRc(VM* vm, void* ptr);
214VAL MKPTRc(VM* vm, void* ptr);
240VAL MKMPTRc(VM* vm, void* ptr, size_t size);
215VAL MKMPTRc(VM* vm, void* ptr, size_t size);
241−VAL MKBUFFERc(VM* vm, Buffer* buf);
242
216
243char* GETSTROFF(VAL stroff);
217char* GETSTROFF(VAL stroff);
244
218
@@ -341,9 +315,6 @@ VAL idris_strCons(VM* vm, VAL x, VAL xs);
341VAL idris_strIndex(VM* vm, VAL str, VAL i);
315VAL idris_strIndex(VM* vm, VAL str, VAL i);
342VAL idris_strRev(VM* vm, VAL str);
316VAL idris_strRev(VM* vm, VAL str);
343
317
344−// Buffer primitives
345−VAL idris_buffer_allocate(VM* vm, VAL hint);
346−VAL idris_appendBuffer(VM* vm, VAL fst, VAL fstLen, VAL cnt, VAL sndLen, VAL sndOff, VAL snd);
347VAL idris_appendB8Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
318VAL idris_appendB8Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
348VAL idris_appendB16Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
319VAL idris_appendB16Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
349VAL idris_appendB16LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
320VAL idris_appendB16LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
src/IRTS/CodegenC.hs−19
@@ -182,10 +182,6 @@ bcc i (ASSIGNCONST l c)
182 mkConst (B16 x) = "idris_b16const(vm, " ++ show x ++ "U)"
182 mkConst (B16 x) = "idris_b16const(vm, " ++ show x ++ "U)"
183 mkConst (B32 x) = "idris_b32const(vm, " ++ show x ++ "UL)"
183 mkConst (B32 x) = "idris_b32const(vm, " ++ show x ++ "UL)"
184 mkConst (B64 x) = "idris_b64const(vm, " ++ show x ++ "ULL)"
184 mkConst (B64 x) = "idris_b64const(vm, " ++ show x ++ "ULL)"
185− mkConst (B8V x) = let x' = V.toList x in "MKB8x16const(vm, " ++ intercalate ", " (map (\elem -> show elem ++ "U") x') ++ ")"
186− mkConst (B16V x) = let x' = V.toList x in "MKB16x8const(vm, " ++ intercalate ", " (map (\elem -> show elem ++ "U") x') ++ ")"
187− mkConst (B32V x) = let x' = V.toList x in "MKB32x4const(vm, " ++ intercalate ", " (map (\elem -> show elem ++ "UL") x') ++ ")"
188− mkConst (B64V x) = let x' = V.toList x in "MKB64x2const(vm, " ++ intercalate ", " (map (\elem -> show elem ++ "ULL") x') ++ ")"
189 -- if it's a type constant, we won't use it, but equally it shouldn't
185 -- if it's a type constant, we won't use it, but equally it shouldn't
190 -- report an error. These might creep into generated for various reasons
186 -- report an error. These might creep into generated for various reasons
191 -- (especially if erasure is disabled).
187 -- (especially if erasure is disabled).
@@ -556,11 +552,6 @@ doOp v LStrIndex [x, y] = v ++ "idris_strIndex(vm, " ++ creg x ++ "," ++ creg y
556doOp v LStrRev [x] = v ++ "idris_strRev(vm, " ++ creg x ++ ")"
552doOp v LStrRev [x] = v ++ "idris_strRev(vm, " ++ creg x ++ ")"
557doOp v LStrLen [x] = v ++ "idris_strlen(vm, " ++ creg x ++ ")"
553doOp v LStrLen [x] = v ++ "idris_strlen(vm, " ++ creg x ++ ")"
558
554
559−doOp v LAllocate [x] = v ++ "idris_buffer_allocate(vm, " ++ creg x ++ ")"
560−doOp v LAppendBuffer [a, b, c, d, e, f] = v ++ "idris_appendBuffer(vm, " ++ creg a ++ "," ++ creg b ++ "," ++ creg c ++ "," ++ creg d ++ "," ++ creg e ++ "," ++ creg f ++ ")"
561−doOp v (LAppend ity en) [a, b, c, d] = v ++ "idris_append" ++ intTyName ity ++ show en ++ "(vm, " ++ creg a ++ "," ++ creg b ++ "," ++ creg c ++ "," ++ creg d ++ ")"
562−doOp v (LPeek ity en) [x, y] = v ++ "idris_peek" ++ intTyName ity ++ show en ++ "(vm, " ++ creg x ++ "," ++ creg y ++ ")"
563−
564doOp v LStdIn [] = v ++ "MKPTR(vm, stdin)"
555doOp v LStdIn [] = v ++ "MKPTR(vm, stdin)"
565doOp v LStdOut [] = v ++ "MKPTR(vm, stdout)"
556doOp v LStdOut [] = v ++ "MKPTR(vm, stdout)"
566doOp v LStdErr [] = v ++ "MKPTR(vm, stderr)"
557doOp v LStdErr [] = v ++ "MKPTR(vm, stderr)"
@@ -576,16 +567,6 @@ doOp v (LChInt ITChar) args = doOp v (LChInt ITNative) args
576doOp v (LIntCh ITNative) args = v ++ creg (last args)
567doOp v (LIntCh ITNative) args = v ++ creg (last args)
577doOp v (LIntCh ITChar) args = doOp v (LIntCh ITNative) args
568doOp v (LIntCh ITChar) args = doOp v (LIntCh ITNative) args
578
569
579−doOp v c@(LMkVec IT8 _) args = v ++ "MKB8x16(vm, " ++ (intercalate ", " (map creg args)) ++ ")"
580−doOp v c@(LMkVec IT16 _) args = v ++ "MKB16x8(vm, " ++ (intercalate ", " (map creg args)) ++ ")"
581−doOp v c@(LMkVec IT32 _) args = v ++ "MKB32x4(vm, " ++ (intercalate ", " (map creg args)) ++ ")"
582−doOp v c@(LMkVec IT64 _) args = v ++ "MKB64x2(vm, " ++ (intercalate ", " (map creg args)) ++ ")"
583−
584−doOp v c@(LIdxVec IT8 _) [p, i] = v ++ "idris_IDXB8x16(vm, " ++ creg p ++ ", " ++ creg i ++ ")"
585−doOp v c@(LIdxVec IT16 _) [p, i] = v ++ "idris_IDXB16x8(vm, " ++ creg p ++ ", " ++ creg i ++ ")"
586−doOp v c@(LIdxVec IT32 _) [p, i] = v ++ "idris_IDXB32x4(vm, " ++ creg p ++ ", " ++ creg i ++ ")"
587−doOp v c@(LIdxVec IT64 _) [p, i] = v ++ "idris_IDXB64x2(vm, " ++ creg p ++ ", " ++ creg i ++ ")"
588−
589doOp v LSystemInfo [x] = v ++ "idris_systemInfo(vm, " ++ creg x ++ ")"
570doOp v LSystemInfo [x] = v ++ "idris_systemInfo(vm, " ++ creg x ++ ")"
590doOp v LNoOp args = v ++ creg (last args)
571doOp v LNoOp args = v ++ creg (last args)
591doOp _ op args = error "doOp of (" ++ show op ++ ") not implemented, arguments (" ++ show args ++ ")"
572doOp _ op args = error "doOp of (" ++ show op ++ ") not implemented, arguments (" ++ show args ++ ")"
src/IRTS/Lang.hs−11
@@ -75,22 +75,11 @@ data PrimFn = LPlus ArithTy | LMinus ArithTy | LTimes ArithTy
75 | LFExp | LFLog | LFSin | LFCos | LFTan | LFASin | LFACos | LFATan
75 | LFExp | LFLog | LFSin | LFCos | LFTan | LFASin | LFACos | LFATan
76 | LFSqrt | LFFloor | LFCeil | LFNegate
76 | LFSqrt | LFFloor | LFCeil | LFNegate
77
77
78− -- construction element extraction element insertion
79− | LMkVec NativeTy Int | LIdxVec NativeTy Int | LUpdateVec NativeTy Int
80−
81 | LStrHead | LStrTail | LStrCons | LStrIndex | LStrRev
78 | LStrHead | LStrTail | LStrCons | LStrIndex | LStrRev
82 | LStdIn | LStdOut | LStdErr
79 | LStdIn | LStdOut | LStdErr
83
80
84− -- Buffers
85− | LAllocate
86− | LAppendBuffer
87 -- system info
81 -- system info
88 | LSystemInfo
82 | LSystemInfo
89− -- Note that for Bits8 only Native endianness is actually used
90− -- and the user-exposed interface for Bits8 doesn't mention
91− -- endianness
92− | LAppend IntTy Endianness
93− | LPeek IntTy Endianness
94
83
95 | LFork
84 | LFork
96 | LPar -- evaluate argument anywhere, possibly on another
85 | LPar -- evaluate argument anywhere, possibly on another
src/Idris/Core/Binary.hs−10
@@ -350,11 +350,6 @@ instance Binary Const where
350 putWord8 (fromIntegral . fromEnum $ ity)
350 putWord8 (fromIntegral . fromEnum $ ity)
351 putWord8 (fromIntegral count)
351 putWord8 (fromIntegral count)
352
352
353− B8V x1 -> putWord8 21 >> put x1
354− B16V x1 -> putWord8 22 >> put x1
355− B32V x1 -> putWord8 23 >> put x1
356− B64V x1 -> putWord8 24 >> put x1
357− BufferType -> putWord8 25
358 ManagedPtrType -> putWord8 26
353 ManagedPtrType -> putWord8 26
359 VoidType -> putWord8 27
354 VoidType -> putWord8 27
360 WorldType -> putWord8 28
355 WorldType -> putWord8 28
@@ -395,11 +390,6 @@ instance Binary Const where
395 c <- getWord8
390 c <- getWord8
396 return (AType (ATInt (ITVec (toEnum . fromIntegral $ e) (fromIntegral c))))
391 return (AType (ATInt (ITVec (toEnum . fromIntegral $ e) (fromIntegral c))))
397
392
398− 21 -> fmap B8V get
399− 22 -> fmap B16V get
400− 23 -> fmap B32V get
401− 24 -> fmap B64V get
402− 25 -> return BufferType
403 26 -> return ManagedPtrType
393 26 -> return ManagedPtrType
404 27 -> return VoidType
394 27 -> return VoidType
405 28 -> return WorldType
395 28 -> return WorldType
src/Idris/Core/CaseTree.hs−4
@@ -321,10 +321,6 @@ isConstType (B8 _) (AType (ATInt _)) = True
321isConstType (B16 _) (AType (ATInt _)) = True
321isConstType (B16 _) (AType (ATInt _)) = True
322isConstType (B32 _) (AType (ATInt _)) = True
322isConstType (B32 _) (AType (ATInt _)) = True
323isConstType (B64 _) (AType (ATInt _)) = True
323isConstType (B64 _) (AType (ATInt _)) = True
324−isConstType (B8V _) (AType (ATInt _)) = True
325−isConstType (B16V _) (AType (ATInt _)) = True
326−isConstType (B32V _) (AType (ATInt _)) = True
327−isConstType (B64V _) (AType (ATInt _)) = True
328isConstType _ _ = False
324isConstType _ _ = False
329
325
330data Pat = PCon Bool Name Int [Pat]
326data Pat = PCon Bool Name Int [Pat]
src/Idris/Core/DeepSeq.hs−5
@@ -150,17 +150,12 @@ instance NFData Const where
150 rnf (B16 x1) = rnf x1 `seq` ()
150 rnf (B16 x1) = rnf x1 `seq` ()
151 rnf (B32 x1) = rnf x1 `seq` ()
151 rnf (B32 x1) = rnf x1 `seq` ()
152 rnf (B64 x1) = rnf x1 `seq` ()
152 rnf (B64 x1) = rnf x1 `seq` ()
153− rnf (B8V x1) = rnf x1 `seq` ()
154− rnf (B16V x1) = rnf x1 `seq` ()
155− rnf (B32V x1) = rnf x1 `seq` ()
156− rnf (B64V x1) = rnf x1 `seq` ()
157 rnf (AType x1) = rnf x1 `seq` ()
153 rnf (AType x1) = rnf x1 `seq` ()
158 rnf WorldType = ()
154 rnf WorldType = ()
159 rnf TheWorld = ()
155 rnf TheWorld = ()
160 rnf StrType = ()
156 rnf StrType = ()
161 rnf PtrType = ()
157 rnf PtrType = ()
162 rnf ManagedPtrType = ()
158 rnf ManagedPtrType = ()
163− rnf BufferType = ()
164 rnf VoidType = ()
159 rnf VoidType = ()
165 rnf Forgot = ()
160 rnf Forgot = ()
166
161
src/Idris/Core/TT.hs+1−19
@@ -565,11 +565,9 @@ intTyWidth ITBig = error "IRTS.Lang.intTyWidth: Big integers have variable width
565
565
566data Const = I Int | BI Integer | Fl Double | Ch Char | Str String
566data Const = I Int | BI Integer | Fl Double | Ch Char | Str String
567 | B8 Word8 | B16 Word16 | B32 Word32 | B64 Word64
567 | B8 Word8 | B16 Word16 | B32 Word32 | B64 Word64
568− | B8V (Vector Word8) | B16V (Vector Word16)
569− | B32V (Vector Word32) | B64V (Vector Word64)
570 | AType ArithTy | StrType
568 | AType ArithTy | StrType
571 | WorldType | TheWorld
569 | WorldType | TheWorld
572− | PtrType | ManagedPtrType | BufferType | VoidType | Forgot
570+ | PtrType | ManagedPtrType | VoidType | Forgot
573 deriving (Eq, Ord, Data, Typeable)
571 deriving (Eq, Ord, Data, Typeable)
574{-!
572{-!
575deriving instance Binary Const
573deriving instance Binary Const
@@ -580,7 +578,6 @@ isTypeConst :: Const -> Bool
580isTypeConst (AType _) = True
578isTypeConst (AType _) = True
581isTypeConst StrType = True
579isTypeConst StrType = True
582isTypeConst ManagedPtrType = True
580isTypeConst ManagedPtrType = True
583−isTypeConst BufferType = True
584isTypeConst WorldType = True
581isTypeConst WorldType = True
585isTypeConst PtrType = True
582isTypeConst PtrType = True
586isTypeConst VoidType = True
583isTypeConst VoidType = True
@@ -599,7 +596,6 @@ instance Pretty Const OutputAnnotation where
599 pretty StrType = text "String"
596 pretty StrType = text "String"
600 pretty TheWorld = text "%theWorld"
597 pretty TheWorld = text "%theWorld"
601 pretty WorldType = text "prim__World"
598 pretty WorldType = text "prim__World"
602− pretty BufferType = text "prim__UnsafeBuffer"
603 pretty PtrType = text "Ptr"
599 pretty PtrType = text "Ptr"
604 pretty ManagedPtrType = text "Ptr"
600 pretty ManagedPtrType = text "Ptr"
605 pretty VoidType = text "Void"
601 pretty VoidType = text "Void"
@@ -620,10 +616,6 @@ constIsType (B8 _) = False
620constIsType (B16 _) = False
616constIsType (B16 _) = False
621constIsType (B32 _) = False
617constIsType (B32 _) = False
622constIsType (B64 _) = False
618constIsType (B64 _) = False
623−constIsType (B8V _) = False
624−constIsType (B16V _) = False
625−constIsType (B32V _) = False
626−constIsType (B64V _) = False
627constIsType _ = True
619constIsType _ = True
628
620
629-- | Get the docstring for a Const
621-- | Get the docstring for a Const
@@ -635,7 +627,6 @@ constDocs c@(AType ATFloat) = "Double-precision floating-point nu
635constDocs StrType = "Strings in some unspecified encoding"
627constDocs StrType = "Strings in some unspecified encoding"
636constDocs PtrType = "Foreign pointers"
628constDocs PtrType = "Foreign pointers"
637constDocs ManagedPtrType = "Managed pointers"
629constDocs ManagedPtrType = "Managed pointers"
638−constDocs BufferType = "Copy-on-write buffers"
639constDocs c@(AType (ATInt (ITFixed IT8))) = "Eight bits (unsigned)"
630constDocs c@(AType (ATInt (ITFixed IT8))) = "Eight bits (unsigned)"
640constDocs c@(AType (ATInt (ITFixed IT16))) = "Sixteen bits (unsigned)"
631constDocs c@(AType (ATInt (ITFixed IT16))) = "Sixteen bits (unsigned)"
641constDocs c@(AType (ATInt (ITFixed IT32))) = "Thirty-two bits (unsigned)"
632constDocs c@(AType (ATInt (ITFixed IT32))) = "Thirty-two bits (unsigned)"
@@ -657,10 +648,6 @@ constDocs (B32 w) = "The thirty-two-bit value 0x" ++
657 showIntAtBase 16 intToDigit w ""
648 showIntAtBase 16 intToDigit w ""
658constDocs (B64 w) = "The sixty-four-bit value 0x" ++
649constDocs (B64 w) = "The sixty-four-bit value 0x" ++
659 showIntAtBase 16 intToDigit w ""
650 showIntAtBase 16 intToDigit w ""
660−constDocs (B8V v) = "A vector of eight-bit values"
661−constDocs (B16V v) = "A vector of sixteen-bit values"
662−constDocs (B32V v) = "A vector of thirty-two-bit values"
663−constDocs (B64V v) = "A vector of sixty-four-bit values"
664constDocs prim = "Undocumented"
651constDocs prim = "Undocumented"
665
652
666data Universe = NullType | UniqueType | AllTypes
653data Universe = NullType | UniqueType | AllTypes
@@ -1303,10 +1290,6 @@ instance Show Const where
1303 show (B16 x) = show x
1290 show (B16 x) = show x
1304 show (B32 x) = show x
1291 show (B32 x) = show x
1305 show (B64 x) = show x
1292 show (B64 x) = show x
1306− show (B8V x) = "<" ++ intercalate "," (map show (V.toList x)) ++ ">"
1307− show (B16V x) = "<" ++ intercalate "," (map show (V.toList x)) ++ ">"
1308− show (B32V x) = "<" ++ intercalate "," (map show (V.toList x)) ++ ">"
1309− show (B64V x) = "<" ++ intercalate "," (map show (V.toList x)) ++ ">"
1310 show (AType ATFloat) = "Float"
1293 show (AType ATFloat) = "Float"
1311 show (AType (ATInt ITBig)) = "Integer"
1294 show (AType (ATInt ITBig)) = "Integer"
1312 show (AType (ATInt ITNative)) = "Int"
1295 show (AType (ATInt ITNative)) = "Int"
@@ -1316,7 +1299,6 @@ instance Show Const where
1316 show TheWorld = "prim__TheWorld"
1299 show TheWorld = "prim__TheWorld"
1317 show WorldType = "prim__WorldType"
1300 show WorldType = "prim__WorldType"
1318 show StrType = "String"
1301 show StrType = "String"
1319− show BufferType = "prim__UnsafeBuffer"
1320 show PtrType = "Ptr"
1302 show PtrType = "Ptr"
1321 show ManagedPtrType = "ManagedPtr"
1303 show ManagedPtrType = "ManagedPtr"
1322 show VoidType = "Void"
1304 show VoidType = "Void"
src/Idris/Core/Typecheck.hs−4
@@ -151,10 +151,6 @@ check' holes ctxt env top = chk (TType (UVar (-5))) env top where
151 constType (B16 _) = Constant (AType (ATInt (ITFixed IT16)))
151 constType (B16 _) = Constant (AType (ATInt (ITFixed IT16)))
152 constType (B32 _) = Constant (AType (ATInt (ITFixed IT32)))
152 constType (B32 _) = Constant (AType (ATInt (ITFixed IT32)))
153 constType (B64 _) = Constant (AType (ATInt (ITFixed IT64)))
153 constType (B64 _) = Constant (AType (ATInt (ITFixed IT64)))
154− constType (B8V a) = Constant (AType (ATInt (ITVec IT8 (V.length a))))
155− constType (B16V a) = Constant (AType (ATInt (ITVec IT16 (V.length a))))
156− constType (B32V a) = Constant (AType (ATInt (ITVec IT32 (V.length a))))
157− constType (B64V a) = Constant (AType (ATInt (ITVec IT64 (V.length a))))
158 constType TheWorld = Constant WorldType
154 constType TheWorld = Constant WorldType
159 constType Forgot = Erased
155 constType Forgot = Erased
160 constType _ = TType (UVal 0)
156 constType _ = TType (UVal 0)
src/Idris/ElabTerm.hs−5
@@ -2586,10 +2586,6 @@ reflectConstant c@(B8 _) = reflCall "B8" [RConstant c]
2586reflectConstant c@(B16 _) = reflCall "B16" [RConstant c]
2586reflectConstant c@(B16 _) = reflCall "B16" [RConstant c]
2587reflectConstant c@(B32 _) = reflCall "B32" [RConstant c]
2587reflectConstant c@(B32 _) = reflCall "B32" [RConstant c]
2588reflectConstant c@(B64 _) = reflCall "B64" [RConstant c]
2588reflectConstant c@(B64 _) = reflCall "B64" [RConstant c]
2589−reflectConstant (B8V ws) = reflCall "B8V" [mkList (Var (sUN "Bits8")) . map (RConstant . B8) . V.toList $ ws]
2590−reflectConstant (B16V ws) = reflCall "B8V" [mkList (Var (sUN "Bits16")) . map (RConstant . B16) . V.toList $ ws]
2591−reflectConstant (B32V ws) = reflCall "B8V" [mkList (Var (sUN "Bits32")) . map (RConstant . B32) . V.toList $ ws]
2592−reflectConstant (B64V ws) = reflCall "B8V" [mkList (Var (sUN "Bits64")) . map (RConstant . B64) . V.toList $ ws]
2593reflectConstant (AType (ATInt ITNative)) = reflCall "AType" [reflCall "ATInt" [Var (reflm "ITNative")]]
2589reflectConstant (AType (ATInt ITNative)) = reflCall "AType" [reflCall "ATInt" [Var (reflm "ITNative")]]
2594reflectConstant (AType (ATInt ITBig)) = reflCall "AType" [reflCall "ATInt" [Var (reflm "ITBig")]]
2590reflectConstant (AType (ATInt ITBig)) = reflCall "AType" [reflCall "ATInt" [Var (reflm "ITBig")]]
2595reflectConstant (AType ATFloat) = reflCall "AType" [Var (reflm "ATFloat")]
2591reflectConstant (AType ATFloat) = reflCall "AType" [Var (reflm "ATFloat")]
@@ -2605,7 +2601,6 @@ reflectConstant (AType (ATInt (ITVec IT32 c))) = reflCall "AType" [reflCall "ATI
2605reflectConstant (AType (ATInt (ITVec IT64 c))) = reflCall "AType" [reflCall "ATInt" [reflCall "ITVec" [Var (reflm "IT64"), RConstant (I c)]]]
2601reflectConstant (AType (ATInt (ITVec IT64 c))) = reflCall "AType" [reflCall "ATInt" [reflCall "ITVec" [Var (reflm "IT64"), RConstant (I c)]]]
2606reflectConstant PtrType = Var (reflm "PtrType")
2602reflectConstant PtrType = Var (reflm "PtrType")
2607reflectConstant ManagedPtrType = Var (reflm "ManagedPtrType")
2603reflectConstant ManagedPtrType = Var (reflm "ManagedPtrType")
2608−reflectConstant BufferType = Var (reflm "BufferType")
2609reflectConstant VoidType = Var (reflm "VoidType")
2604reflectConstant VoidType = Var (reflm "VoidType")
2610reflectConstant Forgot = Var (reflm "Forgot")
2605reflectConstant Forgot = Var (reflm "Forgot")
2611reflectConstant WorldType = Var (reflm "WorldType")
2606reflectConstant WorldType = Var (reflm "WorldType")
src/Idris/IdeMode.hs−4
@@ -113,10 +113,6 @@ constTy (B8 _) = "Bits8"
113constTy (B16 _) = "Bits16"
113constTy (B16 _) = "Bits16"
114constTy (B32 _) = "Bits32"
114constTy (B32 _) = "Bits32"
115constTy (B64 _) = "Bits64"
115constTy (B64 _) = "Bits64"
116−constTy (B8V _) = "Bits8x16"
117−constTy (B16V _) = "Bits16x8"
118−constTy (B32V _) = "Bits32x4"
119−constTy (B64V _) = "Bits64x2"
120constTy _ = "Type"
116constTy _ = "Type"
121
117
122instance SExpable OutputAnnotation where
118instance SExpable OutputAnnotation where
src/Idris/Primitives.hs−215
@@ -190,17 +190,9 @@ primitives =
190 -- Managed pointer registration
190 -- Managed pointer registration
191 Prim (sUN "prim__registerPtr") (ty [PtrType, AType (ATInt ITNative)] ManagedPtrType) 2 (p_cantreduce)
191 Prim (sUN "prim__registerPtr") (ty [PtrType, AType (ATInt ITNative)] ManagedPtrType) 2 (p_cantreduce)
192 (2, LRegisterPtr) total,
192 (2, LRegisterPtr) total,
193− -- Buffers
194− Prim (sUN "prim__allocate") (ty [AType (ATInt (ITFixed IT64))] BufferType) 1 (p_allocate)
195− (1, LAllocate) total,
196− Prim (sUN "prim__appendBuffer") (ty [BufferType, AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), BufferType] BufferType) 6 (p_appendBuffer)
197− (6, LAppendBuffer) partial,
198 Prim (sUN "prim__systemInfo") (ty [AType (ATInt ITNative)] StrType) 1 (p_cantreduce)
193 Prim (sUN "prim__systemInfo") (ty [AType (ATInt ITNative)] StrType) 1 (p_cantreduce)
199 (1, LSystemInfo) total
194 (1, LSystemInfo) total
200 ] ++ concatMap intOps [ITFixed IT8, ITFixed IT16, ITFixed IT32, ITFixed IT64, ITBig, ITNative, ITChar]
195 ] ++ concatMap intOps [ITFixed IT8, ITFixed IT16, ITFixed IT32, ITFixed IT64, ITBig, ITNative, ITChar]
201− ++ concatMap vecOps vecTypes
202− ++ concatMap fixedOps [ITFixed IT8, ITFixed IT16, ITFixed IT32, ITFixed IT64] -- ITNative, ITChar, ATFloat ] ++ vecTypes
203− ++ vecBitcasts vecTypes
204
196
205vecTypes :: [IntTy]
197vecTypes :: [IntTy]
206vecTypes = [ITVec IT8 16, ITVec IT16 8, ITVec IT32 4, ITVec IT64 2]
198vecTypes = [ITVec IT8 16, ITVec IT16 8, ITVec IT32 4, ITVec IT64 2]
@@ -270,48 +262,11 @@ vecCmps ity =
270 , iCmp ity "gt" True (bCmp ity (>)) LGt total
262 , iCmp ity "gt" True (bCmp ity (>)) LGt total
271 ]
263 ]
272
264
273−-- The TODOs in this function are documented as Issue #1617 on the issue tracker.
274−--
275−-- https://github.com/idris-lang/Idris-dev/issues/1617
276−vecOps :: IntTy -> [Prim]
277−vecOps ity@(ITVec elem count) =
278− [ Prim (sUN $ "prim__mk" ++ intTyName ity)
279− (ty (replicate count . AType . ATInt . ITFixed $ elem) (AType . ATInt $ ity))
280− count (mkVecCon elem count) (count, LMkVec elem count) total
281− , Prim (sUN $ "prim__index" ++ intTyName ity)
282− (ty [AType . ATInt $ ity, AType (ATInt (ITFixed IT32))] (AType . ATInt . ITFixed $ elem))
283− 2 (mkVecIndex count) (2, LIdxVec elem count) partial -- TODO: Ensure this reduces
284− , Prim (sUN $ "prim__update" ++ intTyName ity)
285− (ty [AType . ATInt $ ity, AType (ATInt (ITFixed IT32)), AType . ATInt . ITFixed $ elem]
286− (AType . ATInt $ ity))
287− 3 (mkVecUpdate elem count) (3, LUpdateVec elem count) partial -- TODO: Ensure this reduces
288− ] ++ intArith ity ++ vecCmps ity
289−
290bitcastPrim :: ArithTy -> ArithTy -> (ArithTy -> [Const] -> Maybe Const) -> PrimFn -> Prim
265bitcastPrim :: ArithTy -> ArithTy -> (ArithTy -> [Const] -> Maybe Const) -> PrimFn -> Prim
291bitcastPrim from to impl prim =
266bitcastPrim from to impl prim =
292 Prim (sUN $ "prim__bitcast" ++ aTyName from ++ "_" ++ aTyName to) (ty [AType from] (AType to)) 1 (impl to)
267 Prim (sUN $ "prim__bitcast" ++ aTyName from ++ "_" ++ aTyName to) (ty [AType from] (AType to)) 1 (impl to)
293 (1, prim) total
268 (1, prim) total
294
269
295−vecBitcasts :: [IntTy] -> [Prim]
296−vecBitcasts tys = [bitcastPrim from to bitcastVec (LBitCast from to)
297− | from <- map ATInt vecTypes, to <- map ATInt vecTypes, from /= to]
298−
299−fixedOps :: IntTy -> [Prim]
300−fixedOps ity@(ITFixed _) =
301− map appendFun endiannesses ++
302− map peekFun endiannesses
303− where
304− endiannesses = [ Native, LE, BE ]
305− tyName = intTyName ity
306− b64 = AType (ATInt (ITFixed IT64))
307− thisTy = AType $ ATInt ity
308− appendFun en = Prim (sUN $ "prim__append" ++ tyName ++ show en)
309− (ty [BufferType, b64, b64, thisTy] BufferType)
310− 4 (p_append en) (4, LAppend ity en) partial
311− peekFun en = Prim (sUN $ "prim__peek" ++ tyName ++ show en)
312− (ty [BufferType, b64] thisTy)
313− 2 (p_peek ity en) (2, LPeek ity en) partial
314−
315mapHalf :: (V.Unbox a, V.Unbox b) => ((a, a) -> b) -> Vector a -> Vector b
270mapHalf :: (V.Unbox a, V.Unbox b) => ((a, a) -> b) -> Vector a -> Vector b
316mapHalf f xs = V.generate (V.length xs `div` 2) (\i -> f (xs V.! (i*2), xs V.! (i*2+1)))
271mapHalf f xs = V.generate (V.length xs `div` 2) (\i -> f (xs V.! (i*2), xs V.! (i*2+1)))
317
272
@@ -339,76 +294,6 @@ truncWord64 :: Bool -> Word64 -> Word32
339truncWord64 True x = fromIntegral (x `shiftR` 32)
294truncWord64 True x = fromIntegral (x `shiftR` 32)
340truncWord64 False x = fromIntegral x
295truncWord64 False x = fromIntegral x
341
296
342−bitcastVec :: ArithTy -> [Const] -> Maybe Const
343−bitcastVec (ATInt (ITVec IT8 n)) [x@(B8V v)]
344− | V.length v == n = Just x
345−bitcastVec (ATInt (ITVec IT16 n)) [B8V v]
346− | V.length v == n*2 = Just . B16V . mapHalf concatWord8 $ v
347−bitcastVec (ATInt (ITVec IT32 n)) [B8V v]
348− | V.length v == n*4 = Just . B32V . mapHalf concatWord16 . mapHalf concatWord8 $ v
349−bitcastVec (ATInt (ITVec IT64 n)) [B8V v]
350− | V.length v == n*8 = Just . B64V . mapHalf concatWord32 . mapHalf concatWord16 . mapHalf concatWord8 $ v
351−
352−bitcastVec (ATInt (ITVec IT8 n)) [B16V v]
353− | V.length v * 2 == n = Just . B8V . mapDouble truncWord16 $ v
354−bitcastVec (ATInt (ITVec IT16 n)) [x@(B16V v)]
355− | V.length v == n = Just x
356−bitcastVec (ATInt (ITVec IT32 n)) [B16V v]
357− | V.length v == n*2 = Just . B32V . mapHalf concatWord16 $ v
358−bitcastVec (ATInt (ITVec IT64 n)) [B16V v]
359− | V.length v == n*4 = Just . B64V . mapHalf concatWord32 . mapHalf concatWord16 $ v
360−
361−bitcastVec (ATInt (ITVec IT8 n)) [B32V v]
362− | V.length v * 4 == n = Just . B8V . mapDouble truncWord16 . mapDouble truncWord32 $ v
363−bitcastVec (ATInt (ITVec IT16 n)) [B32V v]
364− | V.length v * 2 == n = Just . B16V . mapDouble truncWord32 $ v
365−bitcastVec (ATInt (ITVec IT32 n)) [x@(B32V v)]
366− | V.length v == n = Just x
367−bitcastVec (ATInt (ITVec IT64 n)) [B32V v]
368− | V.length v == n*2 = Just . B64V . mapHalf concatWord32 $ v
369−
370−bitcastVec (ATInt (ITVec IT8 n)) [B64V v]
371− | V.length v * 8 == n = Just . B8V . mapDouble truncWord16 . mapDouble truncWord32 . mapDouble truncWord64 $ v
372−bitcastVec (ATInt (ITVec IT16 n)) [B64V v]
373− | V.length v * 4 == n = Just . B16V . mapDouble truncWord32 . mapDouble truncWord64 $ v
374−bitcastVec (ATInt (ITVec IT32 n)) [B64V v]
375− | V.length v == n*2 = Just . B32V . mapDouble truncWord64 $ v
376−bitcastVec (ATInt (ITVec IT64 n)) [x@(B64V v)]
377− | V.length v == n = Just x
378−
379−bitcastVec _ _ = Nothing
380−
381−mkVecCon :: NativeTy -> Int -> [Const] -> Maybe Const
382−mkVecCon ity count args
383− | length ints == count = Just (mkVec ity count ints)
384− | otherwise = Nothing
385− where
386− ints = getInt args
387− mkVec :: NativeTy -> Int -> [Integer] -> Const
388− mkVec IT8 len values = B8V $ V.generate len (fromInteger . (values !!))
389− mkVec IT16 len values = B16V $ V.generate len (fromInteger . (values !!))
390− mkVec IT32 len values = B32V $ V.generate len (fromInteger . (values !!))
391− mkVec IT64 len values = B64V $ V.generate len (fromInteger . (values !!))
392−
393−mkVecIndex count [vec, B32 i] = Just (idxVec vec)
394− where
395− idxVec :: Const -> Const
396− idxVec (B8V v) = B8 $ V.unsafeIndex v (fromIntegral i)
397− idxVec (B16V v) = B16 $ V.unsafeIndex v (fromIntegral i)
398− idxVec (B32V v) = B32 $ V.unsafeIndex v (fromIntegral i)
399− idxVec (B64V v) = B64 $ V.unsafeIndex v (fromIntegral i)
400−mkVecIndex _ _ = Nothing
401−
402−mkVecUpdate ity count [vec, B32 i, newElem] = updateVec vec newElem
403− where
404− updateVec :: Const -> Const -> Maybe Const
405− updateVec (B8V v) (B8 e) = Just . B8V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
406− updateVec (B16V v) (B16 e) = Just . B16V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
407− updateVec (B32V v) (B32 e) = Just . B32V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
408− updateVec (B64V v) (B64 e) = Just . B64V $ V.unsafeUpdate v (V.singleton (fromIntegral i, e))
409− updateVec _ _ = Nothing
410−mkVecUpdate _ _ _ = Nothing
411−
412aTyName :: ArithTy -> String
297aTyName :: ArithTy -> String
413aTyName (ATInt t) = intTyName t
298aTyName (ATInt t) = intTyName t
414aTyName ATFloat = "Float"
299aTyName ATFloat = "Float"
@@ -470,18 +355,6 @@ bsrem (ITFixed IT64) [B64 x, B64 y]
470 = Just $ B64 (fromIntegral (fromIntegral x `rem` fromIntegral y :: Int64))
355 = Just $ B64 (fromIntegral (fromIntegral x `rem` fromIntegral y :: Int64))
471bsrem ITNative [I x, I y] = Just $ I (x `rem` y)
356bsrem ITNative [I x, I y] = Just $ I (x `rem` y)
472bsrem ITChar [Ch x, Ch y] = Just $ Ch (chr $ (ord x) `rem` (ord y))
357bsrem ITChar [Ch x, Ch y] = Just $ Ch (chr $ (ord x) `rem` (ord y))
473−bsrem (ITVec IT8 _) [B8V x, B8V y]
474− = Just . B8V $
475− V.zipWith (\n d -> (fromIntegral (fromIntegral n `rem` fromIntegral d :: Int8))) x y
476−bsrem (ITVec IT16 _) [B16V x, B16V y]
477− = Just . B16V $
478− V.zipWith (\n d -> (fromIntegral (fromIntegral n `rem` fromIntegral d :: Int16))) x y
479−bsrem (ITVec IT32 _) [B32V x, B32V y]
480− = Just . B32V $
481− V.zipWith (\n d -> (fromIntegral (fromIntegral n `rem` fromIntegral d :: Int64))) x y
482−bsrem (ITVec IT64 _) [B64V x, B64V y]
483− = Just . B64V $
484− V.zipWith (\n d -> (fromIntegral (fromIntegral n `rem` fromIntegral d :: Int64))) x y
485bsrem _ _ = Nothing
358bsrem _ _ = Nothing
486
359
487bsdiv :: IntTy -> [Const] -> Maybe Const
360bsdiv :: IntTy -> [Const] -> Maybe Const
@@ -496,18 +369,6 @@ bsdiv (ITFixed IT64) [B64 x, B64 y]
496 = Just $ B64 (fromIntegral (fromIntegral x `div` fromIntegral y :: Int64))
369 = Just $ B64 (fromIntegral (fromIntegral x `div` fromIntegral y :: Int64))
497bsdiv ITNative [I x, I y] = Just $ I (x `div` y)
370bsdiv ITNative [I x, I y] = Just $ I (x `div` y)
498bsdiv ITChar [Ch x, Ch y] = Just $ Ch (chr $ (ord x) `div` (ord y))
371bsdiv ITChar [Ch x, Ch y] = Just $ Ch (chr $ (ord x) `div` (ord y))
499−bsdiv (ITVec IT8 _) [B8V x, B8V y]
500− = Just . B8V $
501− V.zipWith (\n d -> (fromIntegral (fromIntegral n `div` fromIntegral d :: Int8))) x y
502−bsdiv (ITVec IT16 _) [B16V x, B16V y]
503− = Just . B16V $
504− V.zipWith (\n d -> (fromIntegral (fromIntegral n `div` fromIntegral d :: Int16))) x y
505−bsdiv (ITVec IT32 _) [B32V x, B32V y]
506− = Just . B32V $
507− V.zipWith (\n d -> (fromIntegral (fromIntegral n `div` fromIntegral d :: Int64))) x y
508−bsdiv (ITVec IT64 _) [B64V x, B64V y]
509− = Just . B64V $
510− V.zipWith (\n d -> (fromIntegral (fromIntegral n `div` fromIntegral d :: Int64))) x y
511bsdiv _ _ = Nothing
372bsdiv _ _ = Nothing
512
373
513bashr :: IntTy -> [Const] -> Maybe Const
374bashr :: IntTy -> [Const] -> Maybe Const
@@ -522,18 +383,6 @@ bashr (ITFixed IT64) [B64 x, B64 y]
522 = Just $ B64 (fromIntegral (fromIntegral x `shiftR` fromIntegral y :: Int64))
383 = Just $ B64 (fromIntegral (fromIntegral x `shiftR` fromIntegral y :: Int64))
523bashr ITNative [I x, I y] = Just $ I (x `shiftR` y)
384bashr ITNative [I x, I y] = Just $ I (x `shiftR` y)
524bashr ITChar [Ch x, Ch y] = Just $ Ch (chr $ (ord x) `shiftR` (ord y))
385bashr ITChar [Ch x, Ch y] = Just $ Ch (chr $ (ord x) `shiftR` (ord y))
525−bashr (ITVec IT8 _) [B8V x, B8V y]
526− = Just . B8V $
527− V.zipWith (\n d -> (fromIntegral (fromIntegral n `shiftR` fromIntegral d :: Int8))) x y
528−bashr (ITVec IT16 _) [B16V x, B16V y]
529− = Just . B16V $
530− V.zipWith (\n d -> (fromIntegral (fromIntegral n `shiftR` fromIntegral d :: Int16))) x y
531−bashr (ITVec IT32 _) [B32V x, B32V y]
532− = Just . B32V $
533− V.zipWith (\n d -> (fromIntegral (fromIntegral n `shiftR` fromIntegral d :: Int64))) x y
534−bashr (ITVec IT64 _) [B64V x, B64V y]
535− = Just . B64V $
536− V.zipWith (\n d -> (fromIntegral (fromIntegral n `shiftR` fromIntegral d :: Int64))) x y
537bashr _ _ = Nothing
386bashr _ _ = Nothing
538
387
539bUn :: IntTy -> (forall a. Bits a => a -> a) -> [Const] -> Maybe Const
388bUn :: IntTy -> (forall a. Bits a => a -> a) -> [Const] -> Maybe Const
@@ -544,10 +393,6 @@ bUn (ITFixed IT64) op [B64 x] = Just $ B64 (op x)
544bUn ITBig op [BI x] = Just $ BI (op x)
393bUn ITBig op [BI x] = Just $ BI (op x)
545bUn ITNative op [I x] = Just $ I (op x)
394bUn ITNative op [I x] = Just $ I (op x)
546bUn ITChar op [Ch x] = Just $ Ch (chr $ op (ord x))
395bUn ITChar op [Ch x] = Just $ Ch (chr $ op (ord x))
547−bUn (ITVec IT8 _) op [B8V x] = Just . B8V $ V.map op x
548−bUn (ITVec IT16 _) op [B16V x] = Just . B16V $ V.map op x
549−bUn (ITVec IT32 _) op [B32V x] = Just . B32V $ V.map op x
550−bUn (ITVec IT64 _) op [B64V x] = Just . B64V $ V.map op x
551bUn _ _ _ = Nothing
396bUn _ _ _ = Nothing
552
397
553bitBin :: IntTy -> (forall a. (Bits a, Integral a) => a -> a -> a) -> [Const] -> Maybe Const
398bitBin :: IntTy -> (forall a. (Bits a, Integral a) => a -> a -> a) -> [Const] -> Maybe Const
@@ -558,10 +403,6 @@ bitBin (ITFixed IT64) op [B64 x, B64 y] = Just $ B64 (op x y)
558bitBin ITBig op [BI x, BI y] = Just $ BI (op x y)
403bitBin ITBig op [BI x, BI y] = Just $ BI (op x y)
559bitBin ITNative op [I x, I y] = Just $ I (op x y)
404bitBin ITNative op [I x, I y] = Just $ I (op x y)
560bitBin ITChar op [Ch x, Ch y] = Just $ Ch (chr $ op (ord x) (ord y))
405bitBin ITChar op [Ch x, Ch y] = Just $ Ch (chr $ op (ord x) (ord y))
561−bitBin (ITVec IT8 _) op [B8V x, B8V y] = Just . B8V $ V.zipWith op x y
562−bitBin (ITVec IT16 _) op [B16V x, B16V y] = Just . B16V $ V.zipWith op x y
563−bitBin (ITVec IT32 _) op [B32V x, B32V y] = Just . B32V $ V.zipWith op x y
564−bitBin (ITVec IT64 _) op [B64V x, B64V y] = Just . B64V $ V.zipWith op x y
565bitBin _ _ _ = Nothing
406bitBin _ _ _ = Nothing
566
407
567bCmp :: IntTy -> (forall a. (Integral a, Ord a) => a -> a -> Bool) -> [Const] -> Maybe Const
408bCmp :: IntTy -> (forall a. (Integral a, Ord a) => a -> a -> Bool) -> [Const] -> Maybe Const
@@ -572,14 +413,6 @@ bCmp (ITFixed IT64) op [B64 x, B64 y] = Just $ I (if (op x y) then 1 else 0)
572bCmp ITBig op [BI x, BI y] = Just $ I (if (op x y) then 1 else 0)
413bCmp ITBig op [BI x, BI y] = Just $ I (if (op x y) then 1 else 0)
573bCmp ITNative op [I x, I y] = Just $ I (if (op x y) then 1 else 0)
414bCmp ITNative op [I x, I y] = Just $ I (if (op x y) then 1 else 0)
574bCmp ITChar op [Ch x, Ch y] = Just $ I (if (op (ord x) (ord y)) then 1 else 0)
415bCmp ITChar op [Ch x, Ch y] = Just $ I (if (op (ord x) (ord y)) then 1 else 0)
575−bCmp (ITVec IT8 _) op [B8V x, B8V y]
576− = Just . B8V . V.map (\b -> if b then -1 else 0) $ V.zipWith op x y
577−bCmp (ITVec IT16 _) op [B16V x, B16V y]
578− = Just . B16V . V.map (\b -> if b then -1 else 0) $ V.zipWith op x y
579−bCmp (ITVec IT32 _) op [B32V x, B32V y]
580− = Just . B32V . V.map (\b -> if b then -1 else 0) $ V.zipWith op x y
581−bCmp (ITVec IT64 _) op [B64V x, B64V y]
582− = Just . B64V . V.map (\b -> if b then -1 else 0) $ V.zipWith op x y
583bCmp _ _ _ = Nothing
416bCmp _ _ _ = Nothing
584
417
585
418
@@ -717,53 +550,5 @@ p_strCons _ = Nothing
717p_strRev [Str xs] = Just $ Str (reverse xs)
550p_strRev [Str xs] = Just $ Str (reverse xs)
718p_strRev _ = Nothing
551p_strRev _ = Nothing
719
552
720−p_allocate, p_appendBuffer :: [Const] -> Maybe Const
721−p_allocate [B64 _] = Just $ B8V V.empty
722−p_allocate n = Nothing
723−p_appendBuffer [B8V vect1, B64 size1, B64 count, B64 size2, B64 off, B8V vect2] =
724− Just $ B8V (foldl (V.++)
725− (V.slice 0 (fromIntegral size1) vect1)
726− (replicate (fromIntegral count) (V.slice (fromIntegral off) (fromIntegral size2) vect2)))
727−p_appendBuffer n = Nothing
728−p_append :: Endianness -> [Const] -> Maybe Const
729−p_append en [B8V vect, B64 size, B64 count, val] =
730− let bytes = case val of
731− B8 x -> [x]
732− B16 x -> [fromIntegral x, fromIntegral (shiftR x 8)]
733− B32 x -> map (fromIntegral . shiftR x) [0,8..24]
734− B64 x -> map (fromIntegral . shiftR x) [0,8..56]
735− in Just $ B8V (foldl V.snoc
736− (V.slice 0 (fromIntegral size) vect)
737− (concat (replicate (fromIntegral count)
738− (case en of
739− BE -> reverse bytes
740− _ -> bytes))))
741−p_append _ _ = Nothing
742−
743−p_peek :: IntTy -> Endianness -> [Const] -> Maybe Const
744−p_peek (ITFixed IT8) _ [B8V vect, B64 offset] = Just $ B8 (vect V.! fromIntegral offset)
745−p_peek (ITFixed IT16) en [B8V vect, B64 offset] =
746− let bytes = [0..1]
747− in Just $ B16 (foldl (\full byte -> shiftL full 8 .|. fromIntegral (vect V.! (fromIntegral offset+byte)))
748− 0
749− (case en of
750− BE -> bytes
751− _ -> reverse bytes))
752−p_peek (ITFixed IT32) en [B8V vect, B64 offset] =
753− let bytes = [0..1]
754− in Just $ B32 (foldl (\full byte -> shiftL full 8 .|. fromIntegral (vect V.! (fromIntegral offset+byte)))
755− 0
756− (case en of
757− BE -> bytes
758− _ -> reverse bytes))
759−p_peek (ITFixed IT64) en [B8V vect, B64 offset] =
760− let bytes = [0..1]
761− in Just $ B64 (foldl (\full byte -> shiftL full 8 .|. fromIntegral (vect V.! (fromIntegral offset+byte)))
762− 0
763− (case en of
764− BE -> bytes
765− _ -> reverse bytes))
766−p_peek _ _ _ = Nothing
767−
768p_cantreduce :: a -> Maybe b
553p_cantreduce :: a -> Maybe b
769p_cantreduce _ = Nothing
554p_cantreduce _ = Nothing