support sha(thanks to magrosan)
diff --git a/Makefile b/Makefile
index e8f7615..a7850a2 100644
--- a/Makefile
+++ b/Makefile
@@ -21,4 +21,4 @@
 test:
 	$(MAKE) -C test test
 
-.PHONY: test
+.PHONY: test update
diff --git a/gen/Makefile b/gen/Makefile
index ff611f8..84e3f3b 100644
--- a/gen/Makefile
+++ b/gen/Makefile
@@ -4,9 +4,9 @@
 all: $(TARGET)
 sortline: sortline.cpp
 	$(CXX) $(CFLAGS) $< -o $@
-gen_code: gen_code.cpp
+gen_code: gen_code.cpp ../xbyak/xbyak.h
 	$(CXX) $(CFLAGS) $< -o $@
-gen_avx512: gen_avx512.cpp
+gen_avx512: gen_avx512.cpp ../xbyak/xbyak.h
 	$(CXX) $(CFLAGS) $< -o $@
 
 $(TARGET): $(BIN)
diff --git a/gen/gen_code.cpp b/gen/gen_code.cpp
index 60c43a3..7de2259 100644
--- a/gen/gen_code.cpp
+++ b/gen/gen_code.cpp
@@ -1186,16 +1186,24 @@
 
 			{ 0x2E, "ucomisd", T_0F | T_66 | T_EVEX | T_EW1 | T_SAE_X | T_N8, false, 2 },
 			{ 0x2E, "ucomiss", T_0F | T_EVEX | T_EW0 | T_SAE_X | T_N4, false, 2 },
+
+			{ 0xCC, "sha1rnds4", T_0F3A, true, 1 },
+			{ 0xC8, "sha1nexte", T_0F38, false, 1 },
+			{ 0xC9, "sha1msg1", T_0F38, false, 1 },
+			{ 0xCA, "sha1msg2", T_0F38, false, 1 },
+			{ 0xCB, "sha256rnds2", T_0F38, false, 1 },
+			{ 0xCC, "sha256msg1", T_0F38, false, 1 },
+			{ 0xCD, "sha256msg2", T_0F38, false, 1 },
 		};
 		for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
 			const Tbl *p = &tbl[i];
 			std::string type = type2String(p->type);
-			const char *immS1 = p->hasIMM ? ", uint8 imm" : "";
-			const char *immS2 = p->hasIMM ? ", imm" : ", NONE";
-			uint8 pref = p->type & T_66 ? 0x66 : p->type & T_F2 ? 0xF2 : p->type & T_F3 ? 0xF3 : 0;
-			const char *suf = p->type & T_0F38 ? "0x38" : p->type & T_0F3A ? "0x3A" : "NONE";
 			if (p->mode & 1) {
-				printf("void %s(const Xmm& xmm, const Operand& op%s) { opGen(xmm, op, 0x%02X, 0x%02X, isXMM_XMMorMEM%s, %s); }\n", p->name, immS1, p->code, pref, immS2, suf);
+				const char *immS1 = p->hasIMM ? ", uint8 imm" : "";
+				const char *immS2 = p->hasIMM ? ", imm" : ", NONE";
+				const char *pref = p->type & T_66 ? "0x66" : p->type & T_F2 ? "0xF2" : p->type & T_F3 ? "0xF3" : "NONE";
+				const char *suf = p->type & T_0F38 ? "0x38" : p->type & T_0F3A ? "0x3A" : "NONE";
+				printf("void %s(const Xmm& xmm, const Operand& op%s) { opGen(xmm, op, 0x%02X, %s, isXMM_XMMorMEM%s, %s); }\n", p->name, immS1, p->code, pref, immS2, suf);
 			}
 			if (p->mode & 2) {
 				printf("void v%s(const Xmm& xm, const Operand& op%s) { opAVX_X_XM_IMM(xm, op, %s, 0x%02X%s); }\n"
diff --git a/readme.md b/readme.md
index eda7516..f096ed9 100644
--- a/readme.md
+++ b/readme.md
@@ -333,6 +333,7 @@
 
 History
 -------------
+* 2017/Aug/08 ver 5.45 add sha(thanks to magurosan)
 * 2017/Aug/08 ver 5.44 add prefetchw(thanks to rsdubtso)
 * 2017/Jul/12 ver 5.432 reduce warnings of PVS studio
 * 2017/Jul/09 ver 5.431 fix hasRex() (no affect) (thanks to drillsar)
diff --git a/sample/test_util.cpp b/sample/test_util.cpp
index ab69330..ea04a06 100644
--- a/sample/test_util.cpp
+++ b/sample/test_util.cpp
@@ -54,6 +54,7 @@
 		{ Cpu::tSMAP, "smap" },
 		{ Cpu::tHLE, "hle" },
 		{ Cpu::tRTM, "rtm" },
+		{ Cpu::tRTM, "sha" },
 		{ Cpu::tPREFETCHWT1, "prefetchwt1" },
 		{ Cpu::tF16C, "f16c" },
 		{ Cpu::tMOVBE, "movbe" },
diff --git a/test/make_nm.cpp b/test/make_nm.cpp
index f47c418..9f9a40a 100644
--- a/test/make_nm.cpp
+++ b/test/make_nm.cpp
@@ -1331,6 +1331,16 @@
 		put("pinsrq", XMM, REG64|MEM, IMM);
 #endif
 	}
+	void putSHA() const
+	{
+		put("sha1rnds4", XMM, XMM|MEM, IMM);
+		put("sha1nexte", XMM, XMM|MEM);
+		put("sha1msg1", XMM, XMM|MEM);
+		put("sha1msg2", XMM, XMM|MEM);
+		put("sha256rnds2", XMM, XMM|MEM);
+		put("sha256msg1", XMM, XMM|MEM);
+		put("sha256msg2", XMM, XMM|MEM);
+	}
 	void putFpuMem16_32() const
 	{
 		const char tbl[][8] = {
@@ -2319,6 +2329,7 @@
 		putAVX_Y_XM();
 		separateFunc();
 		putFMA();
+		putSHA();
 #endif
 
 #else // USE_AVX
diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h
index a8ddae6..252d948 100644
--- a/xbyak/xbyak.h
+++ b/xbyak/xbyak.h
@@ -105,7 +105,7 @@
 
 enum {
 	DEFAULT_MAX_CODE_SIZE = 4096,
-	VERSION = 0x5440 /* 0xABCD = A.BC(D) */
+	VERSION = 0x5450 /* 0xABCD = A.BC(D) */
 };
 
 #ifndef MIE_INTEGER_TYPE_DEFINED
diff --git a/xbyak/xbyak_mnemonic.h b/xbyak/xbyak_mnemonic.h
index b92aa51..b2495f6 100644
--- a/xbyak/xbyak_mnemonic.h
+++ b/xbyak/xbyak_mnemonic.h
@@ -1,4 +1,4 @@
-const char *getVersionString() const { return "5.44"; }
+const char *getVersionString() const { return "5.45"; }
 void adc(const Operand& op, uint32 imm) { opRM_I(op, imm, 0x10, 2); }
 void adc(const Operand& op1, const Operand& op2) { opRM_RM(op1, op2, 0x10); }
 void adcx(const Reg32e& reg, const Operand& op) { opGen(reg, op, 0xF6, 0x66, isREG32_REG32orMEM, NONE, 0x38); }
@@ -703,6 +703,13 @@
 void sets(const Operand& op) { opR_ModM(op, 8, 0, 0x0F, 0x90 | 8); }//-V524
 void setz(const Operand& op) { opR_ModM(op, 8, 0, 0x0F, 0x90 | 4); }//-V524
 void sfence() { db(0x0F); db(0xAE); db(0xF8); }
+void sha1msg1(const Xmm& xmm, const Operand& op) { opGen(xmm, op, 0xC9, NONE, isXMM_XMMorMEM, NONE, 0x38); }
+void sha1msg2(const Xmm& xmm, const Operand& op) { opGen(xmm, op, 0xCA, NONE, isXMM_XMMorMEM, NONE, 0x38); }
+void sha1nexte(const Xmm& xmm, const Operand& op) { opGen(xmm, op, 0xC8, NONE, isXMM_XMMorMEM, NONE, 0x38); }
+void sha1rnds4(const Xmm& xmm, const Operand& op, uint8 imm) { opGen(xmm, op, 0xCC, NONE, isXMM_XMMorMEM, imm, 0x3A); }
+void sha256msg1(const Xmm& xmm, const Operand& op) { opGen(xmm, op, 0xCC, NONE, isXMM_XMMorMEM, NONE, 0x38); }
+void sha256msg2(const Xmm& xmm, const Operand& op) { opGen(xmm, op, 0xCD, NONE, isXMM_XMMorMEM, NONE, 0x38); }
+void sha256rnds2(const Xmm& xmm, const Operand& op) { opGen(xmm, op, 0xCB, NONE, isXMM_XMMorMEM, NONE, 0x38); }
 void shl(const Operand& op, const Reg8& _cl) { opShift(op, _cl, 4); }
 void shl(const Operand& op, int imm) { opShift(op, imm, 4); }
 void shld(const Operand& op, const Reg& reg, const Reg8& _cl) { opShxd(op, reg, 0, 0xA4, &_cl); }
diff --git a/xbyak/xbyak_util.h b/xbyak/xbyak_util.h
index c2c36d0..82c8b9e 100644
--- a/xbyak/xbyak_util.h
+++ b/xbyak/xbyak_util.h
@@ -176,6 +176,7 @@
 	static const Type tAVX512_4FMAPS = uint64(1) << 45;
 	static const Type tPREFETCHWT1 = uint64(1) << 46;
 	static const Type tPREFETCHW = uint64(1) << 47;
+	static const Type tSHA = uint64(1) << 48;
 
 	Cpu()
 		: type_(NONE)
@@ -254,6 +255,7 @@
 			if (data[1] & (1U << 20)) type_ |= tSMAP;
 			if (data[1] & (1U << 4)) type_ |= tHLE;
 			if (data[1] & (1U << 11)) type_ |= tRTM;
+			if (data[1] & (1U << 29)) type_ |= tSHA;
 			if (data[2] & (1U << 0)) type_ |= tPREFETCHWT1;
 		}
 		setFamily();