From 7e63e06d1ec20de140863e44c703d9f0da596b6e Mon Sep 17 00:00:00 2001 From: Michael Mohr Date: Tue, 28 Dec 2010 12:33:26 -0800 Subject: [PATCH] split out ARM support for Android targets --- Android.mk | 4 ++ src/mont/fp_montgomery_reduce.c | 65 ++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/Android.mk b/Android.mk index dfc98dc..585e47b 100644 --- a/Android.mk +++ b/Android.mk @@ -100,6 +100,10 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) # -ftree-vectorizer-verbose=2: verbose output during compile # Note: not all V7a targets support NEON! # LOCAL_ARM_NEON := true +LOCAL_CFLAGS += -DTFM_ARM_V7A +else ifeq ($(TARGET_ARCH_ABI),armeabi) +LOCAL_CFLAGS += -DTFM_ARM_V5TE +else LOCAL_CFLAGS += -DTFM_ARM endif diff --git a/src/mont/fp_montgomery_reduce.c b/src/mont/fp_montgomery_reduce.c index 6453554..5cc833b 100644 --- a/src/mont/fp_montgomery_reduce.c +++ b/src/mont/fp_montgomery_reduce.c @@ -296,9 +296,6 @@ asm( \ asm( \ " LDR r0,%1 \n\t" \ " ADDS r0,r0,%0 \n\t" \ - #if defined(__thumb2__) \ - " ITE CS \n\t" \ - #endif \ " MOVCS %0,#1 \n\t" \ " MOVCC %0,#0 \n\t" \ " UMLAL r0,%0,%3,%4 \n\t" \ @@ -310,9 +307,65 @@ asm( \ " LDR r0,%1 \n\t" \ " ADDS r0,r0,%0 \n\t" \ " STR r0,%1 \n\t" \ - #if defined(__thumb2__) \ - " ITE CS \n\t" \ - #endif \ + " MOVCS %0,#1 \n\t" \ + " MOVCC %0,#0 \n\t" \ +:"=r"(cy),"=g"(_c[0]):"0"(cy),"1"(_c[0]):"r0","%cc"); + +/******************************************************************/ +#elif defined(TFM_ARM_V7A) + /* Android: armeabi-v7a target */ + +#define MONT_START +#define MONT_FINI +#define LOOP_END +#define LOOP_START \ + mu = c[x] * mp + +#define INNERMUL \ +asm( \ + " LDR r0,%1 \n\t" \ + " ADDS r0,r0,%0 \n\t" \ + " ITE CS \n\t" \ + " MOVCS %0,#1 \n\t" \ + " MOVCC %0,#0 \n\t" \ + " UMLAL r0,%0,%3,%4 \n\t" \ + " STR r0,%1 \n\t" \ +:"=r"(cy),"=g"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c[0]):"r0","%cc"); + +#define PROPCARRY \ +asm( \ + " LDR r0,%1 \n\t" \ + " ADDS r0,r0,%0 \n\t" \ + " STR r0,%1 \n\t" \ + " MOVCS %0,#1 \n\t" \ + " MOVCC %0,#0 \n\t" \ +:"=r"(cy),"=g"(_c[0]):"0"(cy),"1"(_c[0]):"r0","%cc"); + +/******************************************************************/ +#elif defined(TFM_ARM_V5TE) + /* Android: armeabi target */ + +#define MONT_START +#define MONT_FINI +#define LOOP_END +#define LOOP_START \ + mu = c[x] * mp + +#define INNERMUL \ +asm( \ + " LDR r0,%1 \n\t" \ + " ADDS r0,r0,%0 \n\t" \ + " MOVCS %0,#1 \n\t" \ + " MOVCC %0,#0 \n\t" \ + " UMLAL r0,%0,%3,%4 \n\t" \ + " STR r0,%1 \n\t" \ +:"=r"(cy),"=g"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c[0]):"r0","%cc"); + +#define PROPCARRY \ +asm( \ + " LDR r0,%1 \n\t" \ + " ADDS r0,r0,%0 \n\t" \ + " STR r0,%1 \n\t" \ " MOVCS %0,#1 \n\t" \ " MOVCC %0,#0 \n\t" \ :"=r"(cy),"=g"(_c[0]):"0"(cy),"1"(_c[0]):"r0","%cc");