소스 검색

added int64 print

Nicolas Cannasse 8 년 전
부모
커밋
95891db2c0
3개의 변경된 파일16개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 0
      src/hl.h
  2. 6 3
      src/jit.c
  3. 6 0
      src/std/buffer.c

+ 4 - 0
src/hl.h

@@ -123,6 +123,10 @@
 #	endif
 #endif
 
+#ifndef PRId64
+#	define PRId64	"lld"
+#endif
+
 #ifdef __cplusplus
 #	define C_FUNCTION_BEGIN extern "C" {
 #	define C_FUNCTION_END	};

+ 6 - 3
src/jit.c

@@ -917,7 +917,7 @@ static void load( jit_ctx *ctx, preg *r, vreg *v ) {
 static preg *alloc_fpu( jit_ctx *ctx, vreg *r, bool andLoad ) {
 	preg *p = fetch(r);
 	if( p->kind != RFPU ) {
-		if( !IS_FLOAT(r) ) ASSERT(r->t->kind);
+		if( !IS_FLOAT(r) && (IS_64 || r->t->kind != HI64) ) ASSERT(r->t->kind);
 		p = alloc_reg(ctx, RFPU);
 		if( andLoad )
 			load(ctx,p,r);
@@ -936,6 +936,7 @@ static preg *alloc_cpu( jit_ctx *ctx, vreg *r, bool andLoad ) {
 	preg *p = fetch(r);
 	if( p->kind != RCPU ) {
 #		ifndef HL_64
+		if( r->t->kind == HI64 ) return alloc_fpu(ctx,r,andLoad);
 		if( r->size > 4 ) ASSERT(r->size);
 #		endif
 		p = alloc_reg(ctx, RCPU);
@@ -2343,7 +2344,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 				}
 				call_native_consts(ctx, hl_alloc_dynamic, &rt, 1);
 				// copy value to dynamic
-				if( IS_FLOAT(ra) && !IS_64 ) {
+				if( (IS_FLOAT(ra) || ra->size == 8) && !IS_64 ) {
 					preg *tmp = REG_AT(RCPU_SCRATCH_REGS[1]);
 					op64(ctx,MOV,tmp,&ra->stack);
 					op32(ctx,MOV,pmem(&p,Eax,HDYN_VALUE),tmp);
@@ -2404,9 +2405,11 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 				store(ctx, dst, w, true);
 			} else if (ra->t->kind == HF32) {
 				ASSERT(0);
+			} else if( dst->t->kind == HI64 && ra->t->kind == HI32 ) {
+				jit_error("TODO");
 			} else {
 				preg *r = alloc_cpu(ctx,dst,false);
-				copy(ctx, r, fetch(ra), ra->size);
+				copy_from(ctx, r, ra);
 				store(ctx, dst, r, true);
 			}
 			break;

+ 6 - 0
src/std/buffer.c

@@ -143,6 +143,9 @@ static void hl_buffer_addr( hl_buffer *b, void *data, hl_type *t, vlist *stack )
 	case HI32:
 		hl_buffer_str_sub(b,buf,usprintf(buf,32,USTR("%d"),*(int*)data));
 		break;
+	case HI64:
+		hl_buffer_str_sub(b,buf,usprintf(buf,32,USTR("%" PRId64),*(int64*)data));
+		break;
 	case HF32:
 		hl_buffer_str_sub(b,buf,usprintf(buf,32,USTR("%.9f"),*(float*)data));
 		break;
@@ -194,6 +197,9 @@ static void hl_buffer_rec( hl_buffer *b, vdynamic *v, vlist *stack ) {
 	case HI32:
 		hl_buffer_str_sub(b,buf,usprintf(buf,32,USTR("%d"),v->v.i));
 		break;
+	case HI64:
+		hl_buffer_str_sub(b,buf,usprintf(buf,32,USTR("%" PRId64),v->v.i64));
+		break;
 	case HF32:
 		hl_buffer_str_sub(b,buf,usprintf(buf,32,USTR("%.9f"),v->v.f));
 		break;